This ticket represents the work to make isort work the same, by default independent to what environments are loaded or installed. This is increasingly important as isort is being utilized widely within CI/CD systems, where the likely hood that a build system will have a different venv than a developers machine becomes very high.
Suggested approach:
Default finding should do the following on a per import basis:
- CUSTOM: import name exists in any custom specified import sections.
FUTURE: import starts with from __future__
STDLIB: import name exists in comprehensive built in definition of stdlib imports
FIRSTPARTY: import name starts with .
FIRSTPARTY: import code exists within the files isort is told to sort.
FIRSTPARTY: import code exists in same directory as any files isort is told to sort.
THIRDPARTY: Everything else.
In this way, by default isort will not use any magic and will be fully repeatable 🤞. The older approach should be made available via a flag, such as --environment-identifcation-magic and corresponding config option. No optional dependencies (such as toml, setup.py requirements etc) should be used by default, as using these optional dependencies by default is a recipe for non-repeatable runs and user confusion.
Related:
#1058
#1071
#1104
#1098
#1048
#1007
#952
#910
And more that have been closed from previous magic improvement work, though this is the first magic removal attempt.
This ticket represents the work to make isort work the same, by default independent to what environments are loaded or installed. This is increasingly important as isort is being utilized widely within CI/CD systems, where the likely hood that a build system will have a different venv than a developers machine becomes very high.
Suggested approach:
Default finding should do the following on a per import basis:
FUTURE: import starts withfrom __future__STDLIB: import name exists in comprehensive built in definition of stdlib importsFIRSTPARTY: import name starts with.FIRSTPARTY: import code exists within the files isort is told to sort.FIRSTPARTY: import code exists in same directory as any files isort is told to sort.THIRDPARTY: Everything else.In this way, by default isort will not use any magic and will be fully repeatable 🤞. The older approach should be made available via a flag, such as
--environment-identifcation-magicand corresponding config option. No optional dependencies (such as toml, setup.py requirements etc) should be used by default, as using these optional dependencies by default is a recipe for non-repeatable runs and user confusion.Related:
#1058
#1071
#1104
#1098
#1048
#1007
#952
#910
And more that have been closed from previous magic improvement work, though this is the first magic removal attempt.