Skip to content

Make isort venv, or other environment, independent #1147

@timothycrosley

Description

@timothycrosley

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions