How can I specify which files to sort using isort using only the config file? I want to be able to isort . and have it only pick up certain target directories. I'm using pyproject.toml and i've tried
[tool.isort]
profile = "black"
src_paths = ["src", "test"]
and
[tool.isort]
profile = "black"
sources = ["src", "test"]
and
[tool.isort]
profile = "black"
directory = ["src", "test"]
to no avail
I have checked source code of isort am afraid this is as of now it's not possible.
Closest you can get is when using pipenv shortcuts (ofc if used pipenv as package manager) and setup isort shortcut in Pipfile, like:
[scripts]
isort = "isort src tests"
And then call isort using pipenv run isort which will fix all files in both src and tests dirs.
You can as well chain the scripts, so you can e.g. define second script isort_check in Pipfile, which will just check and not correct isort issues:
[scripts]
isort = "isort src test"
isort_check = "pipenv run isort --check-only --diff --color"
Usage will be pipenv run isort_check which proves configuration of directories is defined just in one place (Single Source of Truth principle.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With