-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Black pre-commit hook not respecting pyproject.toml exclude config #1985
Comments
See #438. The problem is that pre-commit passes the files it wants the Black hook to check directly via the CLI instead of letting Black find them by itself. Files directly passed through the CLI aren't subject to the I hope that helps! |
Thanks @ichard26! I'm still struggling to get this set up though. How should I be passing the path to the repos:
- repo: https://github.com/psf/black
rev: b8c1020b526b488a1a216d9a4d58fc8616b61a99
hooks:
- id: black
language_version: python3
args:
- --force-exclude='ignored/' |
repos:
- repo: https://github.com/psf/black
rev: b8c1020b526b488a1a216d9a4d58fc8616b61a99
hooks:
- id: black
language_version: python3
args: [--force-exclude, ignored/] maybe??? (I don't use pre-commit or YAML syntax enough to be 100% sure) You could also just use the |
AHA, yes that would be perfect - I much prefer having a SSOT for these configs 😁. Thank you so much, that worked nicely! For anyone coming across this issue later, this is my exclude = '''
/(
\.eggs
| \.git
| \.venv
| \.env
| build
| dist
| \.mypy_cache
)\
'''
force-exclude = '''
/(
ignored # files in this dir are ignored by pre-commit
)\
''' The example is also visible here. |
Hi, I'm sure I'm missing something, but quick question... My pyproject.toml looks like this:
I find that running |
Describe the bug
The Black pre-commit hook blocks commits containing staged Python files not respecting Black formatting when those files are in the
tool.black
exclude
path inpyproject.toml
. Those files should not be causing the pre-commit hook to fail. When runningblack --check .
at the repo root, the check passes, indicating the issue is specifically with the pre-commit hook.To Reproduce Steps to reproduce the behavior:
Expected behavior
Staged changes that are non-compliant with Black in files that are supposed to be ignored by Black should be able to pass the pre-commit check hook.
Environment (please complete the following information):
Does this bug also happen on master? To answer this, you have two options:
Yes, see here. However, I could only use the commit at the HEAD of
master
on the day I tried this out (today, 2021-02-13), since pre-commit does not allow branchnames for the value ofrev
.Additional context Add any other context about the problem here.
None
The text was updated successfully, but these errors were encountered: