Apply black reformatting to Python files only in regions changed since a given commit. For a practical usage example, see the blog post at https://dev.to/akaihola/improving-python-code-incrementally-3f7a
Describe the bug
We have Django files/settings that have intentional import ordering to avoid issues. Hence, we exclude them when fixing the imports using isort via skip_glob option.
This is the relevant setting in pyproject.toml (--isort option is set in it):
[tool.darker]
isort = true # Run the `isort` also when running `darker`.
[tool.isort]
# https://pycqa.github.io/isort/docs/configuration/options.html
skip_glob = ['*/conf/settings/*'] # Exclude the Settings files due to sensitive imports.
filter_files = true # Exclude the file if applicable even if it's explicitly specified.
Using isort works (i.e. the applicable file is excluded):
However, using darker will still show the --isort diff which is unexpected:
$ darker conf/settings/backoffice.py --diff
...
To Reproduce
Basically, edit a Python file that is part of the skip_glob pattern. Notice that darker will not exclude it when fixing imports.
Expected behavior
Just like the stand-alone isort, darker --isort should exclude the file since it's skipped via glob.
Environment
OS: macOS 12.5 Monterey
Python version: 3.11.0
Git version: 2.39.1
Darker version: 2.1.1
Black version: 24.4.2
Isort version: 5.13.2
Note that when using darker via pre-commit, it's the same issue: those supposed to be skipped files via glob pattern are still being linted by the --isort option which is unexpected.
Describe the bug We have Django files/settings that have intentional import ordering to avoid issues. Hence, we exclude them when fixing the imports using
isort
viaskip_glob
option.This is the relevant setting in
pyproject.toml
(--isort
option is set in it):Using
isort
works (i.e. the applicable file is excluded):However, using
darker
will still show the--isort
diff which is unexpected:To Reproduce Basically, edit a Python file that is part of the
skip_glob
pattern. Notice thatdarker
will not exclude it when fixing imports.Expected behavior Just like the stand-alone
isort
,darker --isort
should exclude the file since it's skipped via glob.Environment
Note that when using
darker
viapre-commit
, it's the same issue: those supposed to be skipped files via glob pattern are still being linted by the--isort
option which is unexpected.PS: Thanks for this excellent project. :)