PyCQA / PyCQA/isort

isort confuses directory for Python package

Open
#2,101 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

isort seems to interpret a directory (containing no __init__.py) as a package.

Example

.
├── a
│   └── example.py
└── b

example.py

import b
import c

In the root directory, I run isort --diff .:

@@ -1,2 +1,3 @@
+import c
+
 import b
-import c

I would expect b not to be interpreted as a local package as the directory doesn't contain an __init__.py file.
Is this the intended behaviour?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report using the shown directory tree and example.py, then run isort --diff . from the root directory. Trace how isort decides whether b is a local package when it lacks __init__.py. Done means the behavior is clarified or corrected so the reported import ordering matches the expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.