-
-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local and CI/CD isort with different behaviour #1889
Comments
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. |
Hey @danielgafni and @matteoettam09, this issue seems relevant to this earlier one: #1790, I don't exactly know if this is applicable here but sharing if this gives any insight. In the meantime, could you provide me the link to the repo so that I could have a look? |
I'm sorry, my project is private. I can only share my observations... the import line that was causing the issue was an import from the "scripts" directory. The project only had one import from this directory. All the other imports were either from standard/external libraries or from the project package. I hope this helps... |
Hi @anirudnits, thank you. My project is unfortunately private as well. In the meantime, I've figured it is possible to run the CI/CD locally, at least with Gitlab, so this could help identify the root cause. |
Can you provide the exact error? Like is this an issue where in the cicd pipeline the import from @matteoettam09 Can you run ~ Aniruddha |
Another private repo here. We have a number of packages pulled directly from gitlab like this in our requirements.txt:
In CI and on one developers machine these are listed as FIRST PARTY. On a second developers machine they are THIRD PARTY as reported by isort. Fixable by using Both developers using virtual environments, (python 3.8.10) but the FIRST PARTY developer has virtualenv as a sub-directory of the main project. The THIRD PARTY developer has a separate /envs directory for virtualenvs in their home directory. Don't know if it helps, just another datapoint. |
Yes! This happened to me too when I moved my .venv directory into my project dir! |
I encounter the same issue. I run isort via pre-commit both locally in docker container and in CircleCI container, both use the same docker image. However locally isort behaves like the right side of the diff, and cicd the left side. default_language_version:
python: python3.8
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
language_version: python3.8
- id: isort
name: isort (cython)
language_version: python3.8
types: [cython]
- id: isort
name: isort (pyi)
language_version: python3.8
types: [pyi] Ps. delta is an open source package delta-spark. Versions: |
same problem encountered as @Magicbeanbuyer, i'm using python 3.8.11 and isrot 5.10.1 (with black profile). could you help here @timothycrosley |
I ran into the same issue and was able to reproduce it here. In my case, the project has the following structure:
If I move |
I got something similar. isort behaves differently at local with
If I run > Skipped 1 files If I run > ERROR: ./airflow/dags/data_dag.py Imports are incorrectly sorted and/or formatted. And the changes from
|
This is duplicated with arguments in .pre-commit-config.yaml because isort is having some issues picking up these config files. isort issue: PyCQA/isort#1889
isort issue: PyCQA/isort#1889 Because of that issue we have our isort config duplicated with arguments in `.pre-commit-config.yaml` and `.isort.cfg`. This was identified in #1037 and is a follow-up to #1030
See comment: pre-commit/pre-commit#2586 (comment) |
No, sorry for the confusion. I just found this issue by searching for |
For me the issue manifested when installing a first party module from a git submodule, it was detected as Firstparty on my system (Windows11 python3.10) and some of the imports were incorrectly detected as Thirdparty on the ci system (Ubuntu20.04 python3.10) with all else being equal. isort vvv outputs local
ci
As workaround I have added the following to my isort config. [settings]
known_first_party=my_package,my_package.something |
@anirudnits can we get the tags on this issue updated? I posted a MWE above, here's the link again |
This is affecting us, too. Has anyone isolated the issue? |
Not sure if related, but I'm seeing things like
I do have more than one foo directory if that matters, but only one is in the Python module search path, and that's the one which also has the scan subdirectory. Now, I'm a first-time isort user so accompanying question: can I just 'merge' sections and tell isort to treat future/stdlib as one section, and have everything else go in another section? I don't really care about whether something is 'third' of 'first' anyway. |
you could try my workaround.
|
@Gornoka yes I'm aware, but I'd really rather not start manually listing modules, that's not really manageable. |
I've seen the same behavior in this job. Locally, In my case, my working copy was in folder named So, in case others run into a similar issue, if your imports match the name of the current folder, you may have unexpected sorting results. |
I had the same issue, where isort would not change my files in local but then fail in the CI/CD job. Tested a lot of stuff, ensuring versions are the same, and even updated my Docker image for the runner. Turns out, we have a folder named "NLTK" within the repo, and the error was happening because
to the |
This same approach solved for me too. |
Problem occurs for me because the pyproject.toml was located at a higher directory level than what I'm trying to isort, so it creates a found-local-dir vs installed-package conflict (because isort treats those differently). My solution was moving the pyproject.toml to be next to the package I'm trying to sort imports in instead of up a directory. Why that only happens in my CI environment and not locally, I don't readily know, but here we are. |
Hello,
have these lines in my .pre-commit.yaml:
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:
Locally I am in a venv, while remotely this is performed inside a docker image:
Any idea why this inconsistency?
Thank you.
The text was updated successfully, but these errors were encountered: