-
-
Notifications
You must be signed in to change notification settings - Fork 584
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
isort does not skip files #885
Comments
Hi @nickgashkov, Can you tell me more about your use case for this? The updated behavior basically makes files you explicitly pass from the command line, assumed non skipped - in all other cases they are skipped (such as when doing recursive sorting). If you do not explicitly pass in that file, but rather a directory it will be skipped. If you pass it in using the API it will also be skipped. I'm curious about the use case where you want to skip files based on a config, but then explicitly pass them in? The reason for this change was that with the old behavior if you say, skipped "build" because you had a build directory inside your project, but then ran in travis which put all your code inside a build directory - you would suddenly be skipping all your files unintentionally. |
Hello @timothycrosley, Thanks for a fast reply. Sorry for unclear description, I didn't know about the behavior of explicitly passed files. The issue can be reproduced with Given the following project structure... ...and the contents of
I've tested the following config...
...and the |
Following up on this, we have an .isort.cnf in a subfolder of our project, as we only want to skip a file in that particular directory. Moving the .isort.cfg to the root folder fixes the problem, but incidentally skips a similarly named file in a different subdirectory. This setup worked with 4.3.4 but not 4.3.11 |
I think, rightly or wrongly, |
I think the
Will skip all directories called migrations not just one directory at the top level. Looking at other examples would suggest it is only suppose to match the exact directory I specified. |
There does appear to be a regression here. In version 4.3.10 the following works:
In version 4.3.11 it now processes files such as |
## Problem isort had a regression in 4.3.11 that it no longer respects `skip_glob` as we intended. See PyCQA/isort#885. This motivated the problem, although there is reason to pin isort regardless of this regression. Linters and autoformatters often change their behavior with new releases. When this happens, we don't want someone's PR to fail due to an unrelated upstream change in that tool's behavior. ## Solution Pin isort to 4.3.10, the most recent release that does not have the `skip_glob` issue. Once this issue gets resolved, the version can be upgraded. Also fix bad imports that weren't caught with our original isort runs. Finally, convert CLI flags to use long names.
I'm sorry for letting this regression slip in the last release! It took a while for me to untangle, but it should be fixed in the latest release (4.3.13) of isort, with additional testing put in place to try to ensure the regression is not reintroduced on the future. Thanks! ~Timothy |
Extra testing -> sounds great! |
Unfortunately doesn't look good :-(. I have:
Version 4.3.13 (unlike 4.3.10) wants to do files such as |
Hi @brianmay, Sorry to hear that! This case should be fixed as well in 4.3.14, with additional testing in place as well :) https://github.com/timothycrosley/isort/releases/tag/4.3.14 Thanks! ~Timothy |
So far that does look a lot better now. Thanks. Have tested with one project, will test with another (more complicated) project tomorrow. |
I'm still having issues with an The config is located (relative to the project root) at with the contents: [settings]
skip=chart.py |
@silasary Are you saying it isn't skipping the |
Correct. The file is in the same subdirectory as the config file. |
@silasary I think isort only looks for |
4.3.12 and up:
4.3.11 has a whole other behavior where lots of files are flagged I assume that's a bad release. 4.3.10 and down:
Why 8 files? I don't know. It was "Skipped 1 file" before I started flipping versions around. I've butted my head against this a little to try and provide a saner report but I can't figure out why it's 8. But it's definitely true that the behavior changes between versions re: .isort.cfg. Any hints on why it's 8 files not 1 file lmk and I'll try and clarify what's happening here. |
Moving the .isort.cfg to the root/working directory and changing it to:
gives "Skipped 3 files" with 4.3.15. Still confused but maybe that's good enough. |
Using the verbose mode, |
Thanks.
OK so I guess we are all good with the new behavior as long as the old behavior was unintentional/doesn't need to be supported. For interest's sake the 8 files skipped under 4.3.10 were:
|
we rely on this behavior in our project. Our use case is next:
Does that make sense? |
This new "never skip when passed a filename" behavior is also a regression in our environment, where we wrap I can also think of cases where A compromise could be a command line option that would opt-in or opt-out of this new behavior. |
Completely agree! I believe 4.3.18 may have included the exact flag that you are hoping for:
Thanks! ~Timothy |
Oh, it drives me mad :) My
There is no .isort.cfg anywhere and neither .editorconfig contains anything related to isort. Observed problem: Files within
isort version: 4.3.21 |
I believe the following should work for you: |
oh, yeah |
Thanks for the tool, its great! |
Hi I also got the same confusions. |
Running into a similar problem. I am trying to use Thanks for your help, @timothycrosley UPDATE: I think I finally got a working solution. Below is my - repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args: [--skip=<FILE_NAME_HERE>, --filter-files] UPDATE 2: never mind, after further trial and error, still no luck here. Final Resolution: Ended up using reorder-python-imports, from the creator of pre-commit. Would love to see a solve to this, as I personally prefer the import style of |
`pre-commit` is known to override behavior from config files in certain instances. This commit fixes known issues for: - `isort` - `black` - `mypy` For relevant details, see: isort: + https://jugmac00.github.io/blog/isort-and-pre-commit-a-friendship-with-obstacles/ + PyCQA/isort#885 black: + psf/black#1584 mypy: + python/mypy#4008 (comment) + https://pre-commit.com/#hooks-pass_filenames
`pre-commit` is known to override behavior from config files in certain instances. This commit fixes known issues for: - `isort` - `black` - `mypy` - `pydocstyle` For relevant details, see: isort: + https://jugmac00.github.io/blog/isort-and-pre-commit-a-friendship-with-obstacles/ + PyCQA/isort#885 black: + psf/black#1584 mypy/pydocstyle: + python/mypy#4008 (comment) + https://pre-commit.com/#hooks-pass_filenames
* refactor(trove-classifiers): update to python 3.7-3.9 * refactor(linters): add `.flake8` and `.codespellrc` configuration files Also add `PullRequest` to `ignore_words.txt` * feat(pyproject): add `pyproject.toml` Currently, this is only use for configuring linters and formatters (no build file specifications are set). Configuration options for `black` and `pydocstyle` are added here in this commit. * feat(pre-commit): add pre-commit * fix(mypy): add `mypy` dependency to `environment.yml` This supports conda test/build environments. * feat(pylint): Update `.pylintrc` Make this match settings specififed in `Makefile`. * feat(test): align checks All checks are placed in appropriate config files. Test runner scripts point to these so that there exists a single source of truth for all configurations and that the tests performed across systems is the same. This may be adjusted, of course, if different settings must be used on a per-system basis. * feat(requirements): add `toml` This package supports reading `pyproject.toml`, which is required for some of our tests. * fix(pre-commit): fix file passing errors `pre-commit` is known to override behavior from config files in certain instances. This commit fixes known issues for: - `isort` - `black` - `mypy` - `pydocstyle` For relevant details, see: isort: + https://jugmac00.github.io/blog/isort-and-pre-commit-a-friendship-with-obstacles/ + PyCQA/isort#885 black: + psf/black#1584 mypy/pydocstyle: + python/mypy#4008 (comment) + https://pre-commit.com/#hooks-pass_filenames * feat(ignores): ignore specific linting errors Ignore linting errors in source code in this PR. The purpose of this PR is to update linting tools. A future PR will correct the errors. This is done to separate concerns. Co-authored-by: Hendry, Adam <adam.hendry@medtronic.com>
Describe the bug
isort
does not respectskip
andskip_glob
configuration options.To Reproduce
Steps to reproduce the behavior:
file.py
with the following content:.isort.cfg
with the following content:isort file.py
.file.py
and check out it's content to become:Expected behavior
A
file.py
is skipped and is not touched.Screenshots
—
Environment (please complete the following information):
Additional context
isort
4.3.10 is working correctly. Issue can be reproduced withskip
option as well.The text was updated successfully, but these errors were encountered: