akaihola / darker

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
https://pypi.org/project/darker/
Other
628 stars 55 forks source link

`isort`: `skip_glob` option doesn't work #615

Open ranelpadon opened 1 month ago

ranelpadon commented 1 month ago

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):

$ isort conf/settings/backoffice.py --diff
Skipped 1 files

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

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.

PS: Thanks for this excellent project. :)

akaihola commented 2 weeks ago

Thanks @ranelpadon for the detailed bug report! I will look into this issue.