-
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
Exclude property is not working in black #1584
Comments
I'd guess it's a problem with the Try changing it to something of this form: # ...
- id: my-hook
exclude: >
(?x)^(
path/to/file1.py|
path/to/file2.py|
path/to/file3.py
)$ |
@hugovk , yes this is working but in this I have to explicitly name each and every file... there are 100s of migration files which I want to exclude.... how can I do that... something like |
Ah yes, you're already excluding from Black's config in But the Black exclude list is ignored when run from pre-commit. This sounds like a duplicate of #438. There's a few suggestions in there.
|
@hugovk But exclude is working fine in python3 project but not in python2. Can this be related to python version as well ? |
Black only works with Python 3. |
No... it only wants python3 environment and it works for python 2 files as well. It is working in my case |
Okay, it shouldn't matter which sort of files you're processing with Black. I suggest you do number 2 above, or if that doesn't work, create a minimal Git repo of your setup to demonstrate. |
The solutions provided by @ hugovk are correct ( To OP: please reply with more information (a reproducible case would be ideal!) if you are still hitting your issue |
`pre-commit` is known to override behavior from config files in certain instances. This commit fixes known issues for: - `isort` - `black` - `mypy` For relevant details, see: isort: + https://jugmac00.github.io/blog/isort-and-pre-commit-a-friendship-with-obstacles/ + PyCQA/isort#885 black: + psf/black#1584 mypy: + python/mypy#4008 (comment) + https://pre-commit.com/#hooks-pass_filenames
`pre-commit` is known to override behavior from config files in certain instances. This commit fixes known issues for: - `isort` - `black` - `mypy` - `pydocstyle` For relevant details, see: isort: + https://jugmac00.github.io/blog/isort-and-pre-commit-a-friendship-with-obstacles/ + PyCQA/isort#885 black: + psf/black#1584 mypy/pydocstyle: + python/mypy#4008 (comment) + https://pre-commit.com/#hooks-pass_filenames
* refactor(trove-classifiers): update to python 3.7-3.9 * refactor(linters): add `.flake8` and `.codespellrc` configuration files Also add `PullRequest` to `ignore_words.txt` * feat(pyproject): add `pyproject.toml` Currently, this is only use for configuring linters and formatters (no build file specifications are set). Configuration options for `black` and `pydocstyle` are added here in this commit. * feat(pre-commit): add pre-commit * fix(mypy): add `mypy` dependency to `environment.yml` This supports conda test/build environments. * feat(pylint): Update `.pylintrc` Make this match settings specififed in `Makefile`. * feat(test): align checks All checks are placed in appropriate config files. Test runner scripts point to these so that there exists a single source of truth for all configurations and that the tests performed across systems is the same. This may be adjusted, of course, if different settings must be used on a per-system basis. * feat(requirements): add `toml` This package supports reading `pyproject.toml`, which is required for some of our tests. * fix(pre-commit): fix file passing errors `pre-commit` is known to override behavior from config files in certain instances. This commit fixes known issues for: - `isort` - `black` - `mypy` - `pydocstyle` For relevant details, see: isort: + https://jugmac00.github.io/blog/isort-and-pre-commit-a-friendship-with-obstacles/ + PyCQA/isort#885 black: + psf/black#1584 mypy/pydocstyle: + python/mypy#4008 (comment) + https://pre-commit.com/#hooks-pass_filenames * feat(ignores): ignore specific linting errors Ignore linting errors in source code in this PR. The purpose of this PR is to update linting tools. A future PR will correct the errors. This is done to separate concerns. Co-authored-by: Hendry, Adam <[email protected]>
Describe the bug A clear and concise description of what the bug is.
Giving a file name to be excluded while running black via pre-commit is not excluding that file and formatting it.
To Reproduce Steps to reproduce the behavior:
.pre-commit-config.yml file
My pyproject.toml file
Here I have explicitly given the name of the file to be excluded i.e.
apps/core/migrations/0002_auto_20200707_1828.py
3. See error
This file is not excluded. Here is the snapshot for running black command.
apps/core/migrations/0002_auto_20200707_1828.py
got successfully formatted.How can I fix this?
Please help!
Thanks!
The text was updated successfully, but these errors were encountered: