PyCQA / PyCQA/isort

How to classify local folders as first party modules except venv

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

Let's say that my project has a structure as such:

root
--package1
----module1
------submodule1
----module2
--package2
----module1
----module2
--venv

I could import every single module starting from root, like from root.package1.module1.submodule1 import function, but I feel like when importing into package1.module2, the prettier way of doing so would be from module1.submodule1 import function, but then it's recognized as third party module. I've tried adding this to pyproject.toml
[tool.isort] src_paths=['root'] virtual_env=['venv']
or
[tool.isort] src_paths=['root'] known_third_party=['venv']
but both of them seem to ignore venv and classify every third and first party modules into the same group.
How do I go around this?

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

Start by reviewing the [tool.isort] configuration examples in the issue, especially src_paths, virtual_env, and known_third_party, then trace how isort classifies imports from the shown project structure. Done would mean a documented or tested configuration that separates local modules from third-party imports while excluding venv.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.