PyCQA / PyCQA/isort

Third-party incorrectly identify as First-party depending on the name of the root directory

Open
#2,240 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

Third-party packages are incorrectly identify as First-party depending on the name of the root directory. I can't find a setting to override this behaviour. Example:

tree:

some_name
|-package_name
|--__init__.py
|--file1.py
|-tests
|-docs
|-pyproject.toml

What isort thinks it should be:

import datetime

import third_party

from package_name.file1 import xyz
from some_name import xyz

What it should be:

import datetime

import third_party
from some_name import xyz

from package_name.file1 import xyz

If I rename the root directory (some_name -> some_other_name), but this means for the CI run I have to also rename the repository.

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 classification using the shown package tree, including pyproject.toml, package_name/init.py, and file1.py, while changing only the root directory name. Trace the import classification entry point and verify that package_name remains third-party and some_name remains first-party regardless of the root directory name.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.