Skip to content

Change isort config and turn on isort in CI #4288

Closed

Description

@JelleZijlstra

While trying to land isort in CI in #3329, I discovered that the behavior of our current isort config depends on whether some modules (e.g., typing_extensions) are installed in the runtime environment where isort is run. This is bad because it means that contributors running isort locally may get different behavior depending on what libraries they happen to have installed in their local environment.

I'm guessing that this has to do with isort's behavior of sorting imports into "sections" of standard library, third-party, and first-party imports. Looking at https://github.com/timothycrosley/isort/wiki/isort-Settings, maybe we need to set default_section? Perhaps we should also mark typing-extensions and _typeshed as "standard library" because in the context of typeshed, they essentially are part of the standard library.

Activity

  1. hauntsaninja commented on Jun 28, 2020

    @hauntsaninja
    Collaborator

    The two options I can see are:

    • Set virtual_env to some random folder. This should hopefully guarantee that isort isn't dependent on contributors' environments.
    • Set default_section to THIRDPARTY, so that whether or not isort detects a library the resulting section is hopefully the same. This might have slightly worse ordering though?

    I'm in favour of explicitly marking those as "standard library".

  2. added a commit that references this issue on Jun 29, 2020
    7dbf10e
  3. added a commit that references this issue on Jun 29, 2020
    0142a87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions