You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the if is_stdin or p.is_file() branch, there's no checking of extend_exclude or exclude patterns, only force_exclude. That's why --extend-exclude has no effect.
Proposed solution
Given the root cause above, the solution should be straightforward.
The text was updated successfully, but these errors were encountered:
I would argue that the documentation around exclude, extend-exclude, and force-exclude is very confusing.
Does force-exclude replace exclude? Or does it add on top of exclude?
And if users have to use force-exclude in pre-commit andforce-exclude replaces exclude, does it mean that we now have to look into Black's code base to find out what the default exclude pattern is?
The code logic may be fine, but I would appreciate additional clarity in the documentation.
Describe the bug
When
Black
is used as a pre-commit hook, the--extend-exclude
option has no effect.To Reproduce
Black
--extend-exclude
Black
directly in the command line (likeblack /folder/that/contains/this/file
)Black
in pre-commitExpected behavior
When
Black
is run directly in the command line, that file is not formatted.When
Black
is run via pre-commit, that file should also not be formatted.Actual behavior
When
Black
is run directly in the command line, that file is not formatted.When
Black
is run via pre-commit, that file is formatted.Environment
main
branchRoot cause
I did some debugging found the root cause: when
Black
is run directly in the command line, this branch is entered:black/src/black/__init__.py
Line 676 in cf4cc29
But when
Black
is run via pre-commit, this branch is entered becausep.is_file()
isTrue
:black/src/black/__init__.py
Line 646 in cf4cc29
In the
if is_stdin or p.is_file()
branch, there's no checking ofextend_exclude
orexclude
patterns, onlyforce_exclude
. That's why--extend-exclude
has no effect.Proposed solution
Given the root cause above, the solution should be straightforward.
The text was updated successfully, but these errors were encountered: