Fix black exclude parameter in pyproject.toml#5216
Merged
Conversation
Contributor
|
You're a star. |
gvwilson
approved these changes
Jun 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@gvwilson observed an issue where running
python commands.py codegenon a fresh pull frommainshows a LARGE number of changed files viagit status. Furthermore the new files seem to not haveblackformatting applied (they are full of single-quoted strings, etc.).This issue turns out to be caused by the
[tool.black]excludeparameter inpyproject.toml. The regular expression was missing a leading and trailing/character, which caused it to match every file path containing one of the listed strings, rather than just including directories with those names.Since the directory
graph_objscontains the stringjs, this caused a significant number of files to be excluded fromblackformatting. Some files were also excluded because their path containeddist.This PR adds leading and trailing
/characters to the regex so that only directories of those names are excluded, as in the example here. (yes, not Windows-friendly but there are already `/'s in the exclude).Ultimately we need to clean all of this up and switch to
ruffbut this is a simple fix in the meantime.How to test
python commands.py codegengit status. You should see zero unstaged changes.You can also run these steps on
mainto compare; runningpython commands.py codegenonmainresults in a large number of unstaged changes.