Local and CI/CD isort with different behaviour
See original GitHub issueHello,
have these lines in my .pre-commit.yaml:
- repo: https://github.com/timothycrosley/isort
rev: 5.9.3 # should be the same as in dev.in
hooks:
- id: isort
and locally I have version 5.9.3 of isort. When I run pre-commit run --all-files locally, the isort is passed succesfully, but when the pre-commit is performed in git, there are some differences:
$ pre-commit run --all-files
Check hooks apply to the repository......................................Passed
Check for useless excludes...............................................Passed
Check Yaml...............................................................Passed
Check for merge conflicts................................................Passed
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
prettier.................................................................Passed
isort....................................................................Failed
- hook id: isort
- files were modified by this hook
Locally I am in a venv, while remotely this is performed inside a docker image:
Running with gitlab-runner 14.6.0 (5316d4ac)
on gitlab_runner_2 UfyZYyEg
Resolving secrets
00:00
Preparing the "docker" executor
00:03
Using Docker executor with image python:3.9 ...
Pulling docker image python:3.9 ...
Using docker image sha256:f88f0508dc467046a760e8ea0bb5c5861ff4e0ade96226ca4700abd1bd28b696 for python:3.9 with digest python@sha256:bf6f8b201ffac79a1b9fded783e7f0547ad2c2e3e48e96a7a23855c3de14df4b ...
Any idea why this inconsistency? Thank you.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:19 (2 by maintainers)
Top Results From Across the Web
isort sorting things differently when running locally than in CI ...
When running isort locally (e.g. python -m isort . or poetry run isort . , isort seems to sort things different than in...
Read more >Using isort with pre-commit
Older versions of isort used a lot of magic to determine import placement, that could easily break when running on CI/CD. To fix...
Read more >How to Make your Code Shine with GitLab CI Pipelines
isort. isort is a tool that sorts imports alphabetically and automatically separated into three main sections: built-ins, third-party and local ...
Read more >Nine simple steps for better-looking python code
When we force behavior, we save precious energy. ... Besides, I have seen how my colleagues use different folders for code ... black...
Read more >README.rst · af012ef18e4680f2b3780d36bca9e3f25fa19a60 ...
If you find the default isort settings do not work well for your project, isort provides several ways to adjust the behavior. To...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I got something similar. isort behaves differently at local with
isort --check--profile black .. In addition, it behaves differently at project root and project sub-directory. Here is my project structure:If I run
isort --check --profile black ./at root. It returns:If I run
isort --check --profile black ./atdagsfolder. It returns:And the changes from
isort --check --diff --profile black ./:I have the same problem. isort suddenly started failing in my CI (in docker), while running it locally doesn’t do anything. isort version is 5.10.1, python 3.8.12.