Closed
Description
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:
check_skip
is always set toFalse
[1] which makeSortImports
not even trying any of the skip options [2] while the class useTrue
as default for that argument [3]- Options defined in a settings-path file are not used [4] by
iter_source_code()
[5], theconfig
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.