You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But doing so the only place where project_root was used is lost. So currently, the project_root variable is initialized but never used.
Instead, if there's a config source (being the directory in which the configuration file is found) the config source is used, that explains why when I set a non empty [tool.isort] in my pyproject.toml, my project root is correctly determined.
So my question is: what is the expected behavior for project root finding?
I see two alternatives:
Either the current behavior is expected, finding a .git or a .hg just make the search for a config file stop without determining the project root.
Either isort should try hard to find the project root and determine it's found when a .git, .hg, pyproject.toml with or without isort config, etc etc is found.
But I have not found a documentation about this, I found #1239 that is related though.
The text was updated successfully, but these errors were encountered:
isort will traverse up to 25 parent directories until it finds a suitable config file. Note that isort will not leave a git or Mercurial repository (checking for a .git or .hg directory). As soon as it finds a file, it stops looking.
If this answers your question, please close this issue to reduce the issue backlog. Thanks!
I found strange that having a
pyproject.toml
with:behaved differently than just having:
So I dug
settings.py
to try to understand the logic.The
_find_config
function tries hard (and succeed) at finding the project root in my case, I typically have a.git/
, it's found, nice.The caller of
_find_config
have a niceproject_root
variable, initialized with the right value for me.But a few lines later I see:
To simplify I see:
So
directory
is always set, so the.get("directory"
is superfluous, it can be simplified as:But doing so the only place where
project_root
was used is lost. So currently, theproject_root
variable is initialized but never used.Instead, if there's a config
source
(being the directory in which the configuration file is found) the config source is used, that explains why when I set a non empty[tool.isort]
in mypyproject.toml
, my project root is correctly determined.So my question is: what is the expected behavior for project root finding?
I see two alternatives:
.git
or a.hg
just make the search for a config file stop without determining the project root..git
,.hg
,pyproject.toml
with or without isort config, etc etc is found.But I have not found a documentation about this, I found #1239 that is related though.
The text was updated successfully, but these errors were encountered: