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
If I have as file named somefile in the root of the project and I want to include it with --include, traditionally the appropriate regex would contain a leading slash:
black --include '^/somefile$' ...
In #3846 this changed, now the leading slash prevents the file from being matched. Instead --include '^somefile$' is required.
The related exclude regexes still need the leading slash.
The cause are the path processing changes in #3846. Slashes are only added to root_relative_path when checking excludes and are now missing from normalized_path, which is later used to check includes.
To Reproduce
$ python3 -m venv venv
$ source venv/bin/activate
$ touch pyproject.toml
$ echo'print( )'> somefile
$ pip install black==23.7.0
...
$ black --check --include '^/somefile$'.
would reformat /home/sth/tst/somefile
Oh no! 💥 💔 💥
1 file would be reformatted.
$ pip install black==23.10.1
...
$ black --check --include '^/somefile$'.
No Python files are present to be formatted. Nothing to do 😴
Expected behavior
The file name matching for --include should work as it did previously, since the change was most likely unintentional and the matching of excludes still works the old way.
Environment
Black's version: 23.10.1
OS and Python version: Ubuntu 22.04, Python 3.10.12
The text was updated successfully, but these errors were encountered:
Describe the bug
If I have as file named
somefile
in the root of the project and I want to include it with--include
, traditionally the appropriate regex would contain a leading slash:In #3846 this changed, now the leading slash prevents the file from being matched. Instead
--include '^somefile$'
is required.The related
exclude
regexes still need the leading slash.The cause are the path processing changes in #3846. Slashes are only added to
root_relative_path
when checking excludes and are now missing fromnormalized_path
, which is later used to check includes.To Reproduce
Expected behavior
The file name matching for
--include
should work as it did previously, since the change was most likely unintentional and the matching of excludes still works the old way.Environment
The text was updated successfully, but these errors were encountered: