Skip to content

Fix black exclude parameter in pyproject.toml #5216

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

Merged
merged 1 commit into from
Jun 5, 2025
Merged

Conversation

emilykl
Copy link
Contributor

@emilykl emilykl commented Jun 4, 2025

@gvwilson observed an issue where running python commands.py codegen on a fresh pull from main shows a LARGE number of changed files via git status. Furthermore the new files seem to not have black formatting applied (they are full of single-quoted strings, etc.).

This issue turns out to be caused by the [tool.black] exclude parameter in pyproject.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_objs contains the string js, this caused a significant number of files to be excluded from black formatting. Some files were also excluded because their path contained dist.

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 ruff but this is a simple fix in the meantime.

How to test

  1. Pull this branch
  2. Run python commands.py codegen
  3. Run git status. You should see zero unstaged changes.

You can also run these steps on main to compare; running python commands.py codegen on main results in a large number of unstaged changes.

@gvwilson
Copy link
Contributor

gvwilson commented Jun 5, 2025

You're a star.

@gvwilson gvwilson merged commit a76b656 into main Jun 5, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants