Open
Conversation
Add `.pre-commit-config.yaml` with the following hooks: - trailing-whitespace, end-of-file-fixer, check-yaml, check-added-large-files (from pre-commit-hooks) - isort (import sorting, picks up `profile = "google"` from pyproject.toml) - pyink (code formatting, local hook using installed pyink) - mypy (type checking, local hook, runs on src/ only) Fixes google#4946
Add step 5 documenting how to install and use pre-commit hooks. Re-numbered subsequent steps accordingly.
Collaborator
|
Hi @brucearctor, Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share. |
Collaborator
|
Hi @xuanyang15 , can you please review this. |
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.
Summary
Add a
.pre-commit-config.yamlto automate running formatting and linting checks before each commit, and updateCONTRIBUTING.mdwith setup instructions.Fixes #4946
Changes
.pre-commit-config.yaml(new)Configures the following hooks:
trailing-whitespaceend-of-file-fixercheck-yamlcheck-added-large-filesisortprofile = "google"frompyproject.toml)pyinkpyproject.toml)mypysrc/only, uses config frompyproject.toml)Design decisions:
pyinkandmypyare configured as local hooks (usinglanguage: system) since they need to use the project's installed versions and configuration. This means contributors must have the dev dependencies installed (uv sync --all-extrasorpip install -e ".[dev]").pylintis intentionally excluded — it's slow on large codebases and is better suited for CI.mypyis scoped tosrc/only, matching the existing[tool.mypy]config which excludestests/andcontributing/samples/.CONTRIBUTING.md(modified)Added a new step 5 ("Install pre-commit hooks") to the Development Setup section with instructions for installing and running pre-commit. Subsequent steps are re-numbered.
Testing Plan
To verify locally: