-
Notifications
You must be signed in to change notification settings - Fork 9
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
Summary
Introduce pre-commit hooks to enforce code and documentation quality automatically before commits. This will improve consistency, reduce CI failures, and streamline development.
Motivation
Currently, formatting and linting are only checked during CI. Adding pre-commit hooks will:
- Catch style and linting issues locally before pushing
- Enforce consistent formatting for Python code and documentation
- Reduce friction during PR reviews
Proposed Hooks
-
Pre-commit hooks for general file checks:
check-toml,check-yaml,trailing-whitespace(from pre-commit-hooks)
-
Python linting with Ruff:
ruffwith--fixand--exit-non-zero-on-fix- ruff-format to auto-format code
-
Documentation formatting with Blacken-docs:
- blacken-docs targeting .rst and .md files
- Using Black 24.10.0 with line length 120, targeting Python 3.12
Example .pre-commit-config.yaml snippet (from my other project):
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-toml
- id: check-yaml
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.10.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.19.1
hooks:
- id: blacken-docs
additional_dependencies: [black==24.10.0]
args: [-l, '120', -t, py312]Scope
- Add
.pre-commit-config.yamlto the repository - Update
CONTRIBUTING.mdandDEV_WORKFLOW.mdwith installation instructions - Ensure hooks are applied consistently by developers
### Acceptance Criteria
- Pre-commit hooks run successfully on a fresh clone
- Developers can install hooks with pre-commit install
- Documentation clearly explains usage
- CI passes with hooks enabled locally
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Type
Projects
Status
No status