Skip to content

isort confuses local modules with third-party imports #2396

@Saransh-cpp

Description

@Saransh-cpp

I have the following directory structure:

.
├── a
│   ├── __init__.py
│   ├── numpy.py
│   └── test.py
├── b
│   └── test.py
└── pyproject.toml

with the following pyproject.toml (isort config):

[tool.isort]
profile = "hug"
src_paths = ["a"]
known_first_party = [
    "a",
]

All the files are empty except b.test.py.

b.test.py sorted by isort

from a.test import *
from numpy import array

b.test.py sorted by isort if I rename the sub-module to say numpyi.py (that is, a.numpyi.py)

from numpy import array

from a.test import *

If I explicitly mark numpy as third-party then everything works well. Is this intentional? I would expect the latter output to be the default one, that is, isort should not treat the numpy import as a local import.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions