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

Add pre-commit configuration to apply Black formatting #418

Merged
merged 8 commits into from
Nov 8, 2023

Conversation

andrewfrench
Copy link
Member

@andrewfrench andrewfrench commented Nov 6, 2023

Adds local pre-commit configuration to enforce Black formatting. If code is not formatted appropriately, the Code Checks workflow will fail. The README has been updated with info on formatting expectations and how to configure pre-commit, which has been added as a dependency using poetry.

Configure pre-commit using poetry:

poetry run pre-commit install

⚠️ Note: this PR also increases the line length configuration from 80 to 120. The large diff is due to running Black after making this change.

Closes #426

@andrewfrench andrewfrench marked this pull request as ready for review November 6, 2023 15:32
@andrewfrench andrewfrench marked this pull request as draft November 6, 2023 15:38
Copy link
Member

Choose a reason for hiding this comment

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

I had originally named this code-checks.yml because I thought we might have other checks (linting, static type checking) in the future. But maybe it's a good idea to separate workflows that make direct changes to the branch vs workflows that just check it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Black formatting was the only job in the workflow, so I felt the name was misleading once it was updated to autocommit. If we want to keep code formatting/style/static analysis stuff in this file I can change the name back.

Copy link
Member Author

Choose a reason for hiding this comment

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

Retained the original Code Checks naming as this now uses pre-commit and PR checks rather than autocommits.

@andrewfrench andrewfrench force-pushed the french/autoformat branch 3 times, most recently from 3e47571 to 0f10f90 Compare November 8, 2023 00:40
@andrewfrench andrewfrench changed the title Autoformat Add pre-commit configuration to apply Black formatting Nov 8, 2023
@andrewfrench andrewfrench marked this pull request as ready for review November 8, 2023 00:43
@collindutter
Copy link
Member

collindutter commented Nov 8, 2023

@andrewfrench based on the number of files changed I assume you also changed the line length to 120? If so, let's update the description to reflect that.

pyproject.toml Outdated Show resolved Hide resolved
collindutter
collindutter previously approved these changes Nov 8, 2023
collindutter
collindutter previously approved these changes Nov 8, 2023
vasinov
vasinov previously approved these changes Nov 8, 2023
@andrewfrench andrewfrench dismissed stale reviews from vasinov and collindutter via eb419e9 November 8, 2023 20:40
@collindutter collindutter merged commit c9aa4c5 into dev Nov 8, 2023
4 checks passed
@andrewfrench andrewfrench deleted the french/autoformat branch November 9, 2023 05:03
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.

3 participants