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
and /tests/another_thing/problem_file.py containing:
fromtests.something.elseimportsome_function
What I was seeing was inconsistent results - when running isort tests --check -v, about half the time I would see tests.something.else module correctly being identified as FIRSTPARTY in its own absolute imports, and the other half of the time, it would be identified as THIRDPARTY.
My clue was the fact that, if you run with --show-config a number of times, you'll see that all of the list orders are nondeterministic between runs. The issue looks to be here:
_src_path is attempting to recurse to figure out if the module is on one of the src_paths or not - but, if the ordering for my run happened to place app first, auto_identify_namespace_packages defaults to True and there's an __init__,py in the app directory, so _is_namespace_package returns True, so it recurses into the app path. But because that's done via return - it never considers the tests entry.
If I change my pyproject.toml to either include auto_identify_namespace_packages = false or use known_local_folder instead of src_paths, I no longer get inconsistent results (and always get what I expect).
The text was updated successfully, but these errors were encountered:
I've been facing an issue in a repo with a structure like:
with the contents of
pyproject.toml
being:and
/tests/another_thing/problem_file.py
containing:What I was seeing was inconsistent results - when running
isort tests --check -v
, about half the time I would seetests.something.else
module correctly being identified asFIRSTPARTY
in its own absolute imports, and the other half of the time, it would be identified asTHIRDPARTY
.My clue was the fact that, if you run with
--show-config
a number of times, you'll see that all of the list orders are nondeterministic between runs. The issue looks to be here:isort/isort/place.py
Lines 76 to 87 in be0fbd0
_src_path
is attempting to recurse to figure out if the module is on one of thesrc_paths
or not - but, if the ordering for my run happened to placeapp
first,auto_identify_namespace_packages
defaults toTrue
and there's an__init__,py
in theapp
directory, so_is_namespace_package
returnsTrue
, so it recurses into theapp
path. But because that's done viareturn
- it never considers thetests
entry.If I change my
pyproject.toml
to either includeauto_identify_namespace_packages = false
or useknown_local_folder
instead ofsrc_paths
, I no longer get inconsistent results (and always get what I expect).The text was updated successfully, but these errors were encountered: