-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Configuration example "exclude" doesn't work as documented #1473
Comments
Same on MaxOSX and Python 3.8 |
Update: you can exclude a file only if it's in the root of the project by prepending So I think the README example should be updated to this: exclude = '''
^/(
(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| foo.py # also separately exclude a file named foo.py in
# the root of the project
)
''' (Note that the forward slash before the second opening paren has been moved to precede the first opening paren so it applies to foo.py as well, and is now also preceded by a Black's default |
The `exclude` section of the example `pyproject.toml` file didn't work as expected. It claimed to exclude matched files only in the project root, but it actually excluded matched files at any directory level within the project. We can address this by prepending `^/` to the regex to ensure that it only matches files in the project root. See psf#1473 (comment) for explanation.
The `exclude` section of the example `pyproject.toml` file didn't work as expected. It claimed to exclude matched files only in the project root, but it actually excluded matched files at any directory level within the project. We can address this by prepending `^/` to the regex to ensure that it only matches files in the project root. See psf#1473 (comment) for explanation.
The `exclude` section of the example `pyproject.toml` file didn't work as expected. It claimed to exclude matched files only in the project root, but it actually excluded matched files at any directory level within the project. We can address this by prepending `^/` to the regex to ensure that it only matches files in the project root. See psf#1473 (comment) for explanation.
* Update example exclude to match only files in root The `exclude` section of the example `pyproject.toml` file didn't work as expected. It claimed to exclude matched files only in the project root, but it actually excluded matched files at any directory level within the project. We can address this by prepending `^/` to the regex to ensure that it only matches files in the project root. See #1473 (comment) for explanation. * Mention excluding directories as well
Describe the bug A clear and concise description of what the bug is.
The example
pyproject.toml
shown in the Configuration format section of the README has the followingexclude
:However, the comment next to foo.py seems to be incorrect. That
foo.py
will actually exclude any foo.py found in the project, not just in the root.To Reproduce Steps to reproduce the behavior:
mkdir temp && cd temp
pyproject.toml
containing the example configuration from abovetouch foo.py
mkdir bar
touch bar/foo.py
black --verbose .
prints the following:Expected behavior A clear and concise description of what you expected to happen.
I would expect Black to not exclude bar/foo.py. It would be nice if there were a way to actually accomplish what the example says (i.e., only exclude foo.py in the project root). Short of that, I think the documentation could use rewording to avoid suggesting that the example pyproject.toml only excludes foo.py in the project root.
Environment (please complete the following information):
Does this bug also happen on master? yes
The text was updated successfully, but these errors were encountered: