PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.53k stars 583 forks source link

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

Open seanswyi opened 1 year ago

seanswyi commented 1 year ago

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.