This repository uses pre-commit hooks to maintain code quality and consistency.
- Install dependencies including pre-commit:
uv sync --group dev --extra cpu- Install the pre-commit hooks:
uv run pre-commit installThe pre-commit configuration includes:
- File validation: YAML, TOML, JSON syntax checking
- Code formatting: Automatic formatting with ruff
- Code linting: Style and error checking with ruff
- Type checking: Static type analysis with mypy (main source code only)
- File hygiene: Trailing whitespace, end-of-file fixes
Pre-commit hooks run automatically on git commit. You can also run them manually:
# Run all hooks on all files
uv run pre-commit run --all-files
# Run specific hook on all files
uv run pre-commit run ruff-check --all-files
# Run hooks on specific files
uv run pre-commit run --files city2graph/utils.py city2graph/graph.pyThe configuration is in .pre-commit-config.yaml and follows OSMnx patterns:
- Excludes notebooks and virtual environments from strict checking
- Uses the same tool versions and configurations as the main project
- Focuses on code quality for the main library code
If pre-commit fails:
- Read the error message carefully
- Fix the issues manually or let auto-fixers handle them
- Stage the changes and commit again
To bypass pre-commit (not recommended):
git commit --no-verify