isort sorting things differently when running locally than in CI/other machines

Viewed 38

When running isort locally (e.g. python -m isort . or poetry run isort ., isort seems to sort things different than in CI, so my CI job fails when it checks for good formatting using python -m isort --check-only ..

Correct:

import azure
import pytest

from my_package_name.example import Example1, Example2

Wrong, running locally

import azure

import pytest
from my_package_name.example import Example1, Example2
1 Answers

Cause

I had an empty folder called pytest, which tricked isort into thinking it was a local module.

Therefore, it moved import pytest together with other local imports.

Solution

After deleting this empty folder, isort sorted the imports correctly again.

Related