dazzling-elephant-33766
02/08/2023, 9:07 AMisort
options set in pyproject.toml
or .isort.cfg
I’ve got an __init__.py
where I don’t want imports to be sorted
➜ example-python git:(main) cat example/__init__.py
from .c import thing # t = 3
from .b import thing # t = 2
from .a import thing # t = 1
I have extend_skip_glob
set in my .isort.cfg
➜ example-python git:(main) ✗ cat .isort.cfg
[settings]
# This is to make isort compatible with Black. See
# <https://black.readthedocs.io/en/stable/the_black_code_style.html#how-black-wraps-lines>.
line_length=88
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
extend_skip_glob=**/__init__.py
The isort binary I have on my path respects this
➜ example-python git:(main) isort example
Skipped 1 files
➜ example-python git:(main) cat example/__init__.py
from .c import thing # t = 3
from .b import thing # t = 2
from .a import thing # t = 1
➜ example-python git:(main) ✗ isort --show-config | jq .extend_skip_glob
[
"**/__init__.py"
]
But running isort
via pants doesn’t
➜ example-python git:(main) ./pants fmt --only=isort example::
17:38:04.58 [WARN] Completed: Format with isort - isort made changes.
example/__init__.py
+ isort made changes.
➜ example-python git:(main) ✗ cat example/__init__.py
from .a import thing # t = 1
from .b import thing # t = 2
from .c import thing # t = 3
Also isn’t respected
./pants fmt --only=isort --isort-args="['--extend-skip-glob=**/__init__.py']"
Any ideas how I can get this to work?refined-addition-53644
02/08/2023, 9:14 AMdazzling-elephant-33766
02/08/2023, 9:20 AMpants.toml
. I’ve tried the equivalent in pyproject.toml
and ran into the same issues.refined-addition-53644
02/08/2023, 9:29 AMdazzling-elephant-33766
02/08/2023, 9:30 AMisort
binary, it’s skipping the __init__.py
(as intended), which is different behaviour from invoking pants fmt ::
➜ example-python git:(main) isort example
Skipped 1 files
➜ example-python git:(main) cat example/__init__.py
from .c import thing # t = 3
from .b import thing # t = 2
from .a import thing # t = 1
(imports remain untouched / same order)refined-addition-53644
02/08/2023, 9:45 AM# pyproject.toml
[tool.isort]
extend_skip = ["__init__.py"]
# pants.toml
[isort]
args = ["--filter-files"]
dazzling-elephant-33766
02/08/2023, 9:51 AM--filter-files
here that I was missing, probably because pants was explicitly passing every file to isort
. Thank you