How do I tell isort that a local import that happens to have the same name as a third party library is a local folder?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7k
- Forks
- 687
- Avg merge
- 4h 56m
- Merged PRs (30d)
- 2
Description
I currently have a directory in my project called common. In my main script I import certain things from this module such as from common import A, B. In my .isort.cfg file I have sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER and so I know that this import statement should be in the last section.
However, whenever I run isort it separates the common import in its own section after STDLIB. Is there any way for me to prevent this?
My entire .isort.cfg file looks like this:
[settings]
multi_line_output=3
lines_after_imports=2
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
[tool.isort]
profile="black"
The imports look like this:
# Before isort
STDLIB
THIRDPARTY
from common import A, B
LOCALFOLDER
# After isort
STDLIB
from common import A, B
THIRDPARTY
LOCALFOLDER
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior using the shown .isort.cfg and the example imports, then trace how isort classifies the common import. Confirm how a project-local module with a name matching a third-party library can be recognized; done means the import is placed in the intended local section without disrupting the other sections.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100