Skip to content
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

10575: Allow black to format migrations + reformat #10578

Merged

Conversation

stevejalim
Copy link
Collaborator

Description

This changeset updates the config for black to no longer ignore the migrations directories, making it consistent with the scope of reach we have for isort.

This means they will be autoformatted in the future, so all existing migrations have been reformatted with black, now, too. Almost all changes are just single quotes to double quotes, plus a file where a hanging indent was improved.

Issue / Bugzilla link

Resolves #10570

Testing

  • have pre-commit running/installed
  • check out this branch
  • make a deliberately unacceptable-to-black edit to a migration file (and to a non-migration python file), stage them and try to commit them - pre-commit will catch them, fix them (but leaving it unstaged for git) and stop the commit, as expected
  • confirm CI is happy

@@ -7,7 +7,6 @@ exclude: >
| assets
| static
| bedrock/externalfiles/files_cache
| ^.*\b(migrations)\b.*$
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this allows pre-commit-driven checks to INCLUDE migrations after all, but changing it up here will also mean the scope of other tools will increase to include migrations. Can you see a reason not to allow this @robhudson ? I'm happy to rework this if it breaks any behaviour you wanted to retain :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that opens it up to flake8 as well which is good. The front-end checks may already filter by extension so that should be fine as well.

@stevejalim stevejalim requested a review from robhudson October 11, 2021 19:14
This brings it into line with isort running on all things.

Note: removing the `migrations` dir from the exclusions will broaden the scope of other tools that pre-commit uses, but this makes sense as black and isort will be targetting these, so why not flake8 too?
@stevejalim stevejalim force-pushed the 10575--allow-black-to-format-migrations branch from c1a4a46 to d4cfb38 Compare October 11, 2021 19:21
@stevejalim stevejalim added Backend Server stuff yo Needs Review Awaiting code review Review: µ Code review time: 5 minutes or less labels Oct 11, 2021
@stevejalim stevejalim requested a review from pmac October 11, 2021 20:06
@@ -6,3 +6,6 @@

# Migrate Python imports using isort
ab38b080abbff26e6968ced9267f3c576bb9e5fa

# Allow Black to reformat migrations
329890d484ff62fc05d6ca764801f56a6baaf748
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on how this merges this may not be right after. Just something to keep an eye on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, it won't fly because it'll be a squashed commit. Will fix after merge

Copy link
Member

@pmac pmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍰

@stevejalim stevejalim merged commit 5f3865d into mozilla:master Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Server stuff yo Needs Review Awaiting code review Review: µ Code review time: 5 minutes or less
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add isort support to Bedrock
3 participants