Skip to content
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

skip and skip-glob are not enforced when using settings-path #909

Closed
rsebille opened this issue Mar 22, 2019 · 2 comments
Closed

skip and skip-glob are not enforced when using settings-path #909

rsebille opened this issue Mar 22, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@rsebille
Copy link

rsebille commented Mar 22, 2019

Hi,

Version used: 4.3.15, not tested on other versions.

Setup:

$ tree -a
.
├── conf
│   └── .isort.cfg
├── file_glob_skip.py
└── file_to_be_skipped.py

1 directory, 3 files
$ cat conf/.isort.cfg 
[isort]
skip =
    file_to_be_skipped.py
skip_glob =
    *glob_skip*
$ cat file_glob_skip.py 
import os

print("Hello World")

import sys
$ cat file_to_be_skipped.py 
import os

print("Hello World")

import sys

Files are not skipped when using --settings-path=conf/.isort.cfg:

$ isort --check-only --settings-path=conf/.isort.cfg
ERROR: /home/romain/Area51/isort_skip_bug/file_glob_skip.py Imports are incorrectly sorted.
ERROR: /home/romain/Area51/isort_skip_bug/file_to_be_skipped.py Imports are incorrectly sorted.

But works when using CLI options:

$ isort --check-only --skip file_to_be_skipped.py --skip-glob '*glob_skip*' 
Skipped 2 files

The problem seems to have two causes:

  1. check_skip is always set to False [1] which make SortImports not even trying any of the skip options [2] while the class use True as default for that argument [3]
  2. Options defined in a settings-path file are not used [4] by iter_source_code() [5], the config dict will only contain options a local .isort.cfg and CLI options.

[1] https://github.com/timothycrosley/isort/blob/4.3.15/isort/main.py#L320
[2] https://github.com/timothycrosley/isort/blob/4.3.15/isort/isort.py#L98
[3] https://github.com/timothycrosley/isort/blob/4.3.15/isort/isort.py#L51
[4] https://github.com/timothycrosley/isort/blob/4.3.15/isort/main.py#L348-L349
[5] https://github.com/timothycrosley/isort/blob/4.3.15/isort/main.py#L353

A bisect give me 91ae94e as first bad commit.

@timothycrosley
Copy link
Member

timothycrosley commented Mar 24, 2019

Thanks for providing such a great detailed bug report for this issue!

This should be fixed in the just released 4.3.16 hotfix:
https://github.com/timothycrosley/isort/releases/tag/4.3.16

Thanks!

~Timothy

@rsebille
Copy link
Author

Thank you for the fix and the release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants