This document describes the pre-commit setup for the CometX repository.
The pre-commit configuration includes the following hooks:
- Black: Code formatting (88 character line length)
- isort: Import sorting (compatible with Black)
- flake8: Linting (with Black-compatible settings)
- pre-commit hooks: Various general checks:
- Merge conflict detection
- YAML/JSON validation
- Large file detection
- Case conflict detection
- Docstring placement
- AST validation
- Debug statement detection
- End-of-file fixing
- Trailing whitespace removal
- TOML validation
- VCS permalink checking
- Mixed line ending detection
- Requirements.txt sorting
- mypy: Type checking (basic mode)
- pydocstyle: Documentation style checking
-
Install development dependencies:
pip install -r requirements-dev.txt
-
Install pre-commit hooks:
pre-commit install
-
(Optional) Run the setup script:
./setup-pre-commit.sh
The automatic hooks will run every time you commit. If any fail, the commit will be blocked until the issues are fixed.
To run the manual hooks:
# Run all manual hooks
pre-commit run --all-files --hook-stage manual
# Run specific manual hooks
pre-commit run mypy --all-files
pre-commit run pydocstyle --all-files# Run all hooks on all files
pre-commit run --all-files
# Run specific hooks
pre-commit run black --all-files
pre-commit run flake8 --all-files
pre-commit run isort --all-files.pre-commit-config.yaml: Main pre-commit configuration.flake8: Flake8 linting configurationpyproject.toml: Black, isort, and mypy configuration
✅ Working Hooks:
- Black (code formatting)
- isort (import sorting)
- flake8 (linting)
- All pre-commit general hooks
- mypy (type checking) - set to manual due to existing type issues
- pydocstyle (documentation) - set to manual due to extensive docstring issues
- Line Length Violations: Some files exceed the 88-character line limit
- Type Annotations: Some files have syntax errors in type annotations
- Documentation: Many functions and classes lack proper docstrings
- Code Quality: Focus on formatting, imports, and linting
To improve the code quality:
- Fix line length violations: Run
pre-commit run black --all-filesto auto-format - Fix type annotations: Address mypy errors in
cometx/framework/comet/download_manager.py - Add docstrings: Gradually add proper documentation to functions and classes
- Improve code quality: Focus on formatting, imports, and linting issues
If you need to bypass pre-commit hooks temporarily:
git commit --no-verify -m "Your commit message"Note: This should only be used in emergencies, not as a regular practice.