[Python] Why does `isort` order the imports differently when renaming a directory from test to...

Discussão em 'Python' iniciado por Stack, Junho 30, 2025.

  1. Stack

    Stack Membro Participativo

    In the example below, everything is already processed using isort . (version 6.0.1):

    tree .


    .
    ├── a
    │ └── test
    │ ├── __init__.py
    │ └── test_integration.py
    └── b
    └── tests
    ├── __init__.py
    └── test_integration.py


    cat ./a/test/test_integration.py


    from test.asdasd import hello

    import numpy as np

    if np.random.random() < 42:
    hello()


    cat ./b/tests/test_integration.py


    import numpy as np
    from tests.asdasd import hello

    if np.random.random() < 42:
    hello()


    Why does isort put from test.asdasd import hello (in a) above import numpy as np, while it puts from tests.asdasd import hello (in b) below import numpy as np?

    Continue reading...

Compartilhe esta Página