Open tehkirill opened 3 weeks ago
Hi @tehkirill
This behavior changed with Ruff 0.6 where the directory src
is now included in the src
setting. You can get back the old behavior by setting src = ["."]
which was the default until Ruff 0.6.
You can read more about it in our blog post.
Thanks for the prompt response and linking to where it was documented, @MichaReiser
In my case - I am using src/
layout - don't think I should exclude it to make this work.
The way it's implemented at the moment makes sense for projects without namespaces, eg ./src/requests
from requests repo.
It does, however, incorrectly identifies a third-party import under the same namespace as first-party, e.g. using an example from packaging.python.org:
mynamespace-subpackage-a/
pyproject.toml
src/
mynamespace/
subpackage_a/
__init__.py
mynamespace-subpackage-b/
pyproject.toml
src/
mynamespace/
subpackage_b/
__init__.py
module_b.py
When working on mynamespace-subpackage-a
, mynamespace-subpackage-b
would be identified as first-party (in fact, anything starting with mynamespace.
would), I don't think it's an expected behaviour.
When working on
mynamespace-subpackage-a
,mynamespace-subpackage-b
would be identified as first-party (in fact, anything starting withmynamespace.
would), I don't think it's an expected behaviour.
That's an interesting edge case! This seems to me to be a general issue with the way our isort
rules detect first-party packages when it comes to namespace packages, that has been exposed in your project by the recent change to isort
's configuration defaults, rather than an issue with the change in defaults itself.
Hi, team. Thanks for your hard work.
I noticed a change in how known-first-party imports get classified recently. If I'm working on
my_namespace.a
project, I expectmy_namespace.b
to be classified as a Known(ThirdParty) (so doesisort
). This was the case with ruff as well, up until version 0.5.7 .Working on
my_namespace.a
project, with the following stucture:^ I see it as a valid import order, so does v0.5.6:
But 0.5.7+ (including the latest 0.6.1) sees otherwise:
Removing
src/my_namespace
correctly classifiesmy_namespace.b
as known-third-party again.