PyCQA / PyCQA/isort

Specifying known_first_party and src_path still causes Isort to group my own module with third party imports.

Open
#2,194 0 comments 5 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

The directory structure of my project is as follows:

.
└── Home/
    └── project/
        ├── data/
        │   ├── dataset.py
        │   └── data_utils.py
        ├── src/
        │   └── main.py
        ├── .pre-commit-config.yaml
        └── .isort.cfg

I also have a .env file that I'm using Python-dotenv to load that has the PYTHONPATH environment variable set to PYTHONPATH="$(pwd):$(pwd)/src:$(pwd)/data" so that I can perform imports from within the data directory.

In the data_utils.py file I have an import that goes from dataset import Dataset. When I run my commits Isort groups from dataset import Dataset with the other third party import statements.

I've tried to specify the following in my .isort.cfg but none of them work:

  1. known_first_party=data_utils
  2. known_first_party=data_utils & src_paths=data

I'm a little stuck as to what else I could try.

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 import classification from data/data_utils.py using the shown .isort.cfg and project layout, with the PYTHONPATH settings described in the issue. Start by checking how isort resolves dataset and the configured src_paths or known_first_party values. Done means the local import is grouped with first-party imports rather than third-party imports.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.