Quality Checks¶
This guide covers the quality assurance tools and workflows to ensure code quality before committing changes.
Overview¶
The project uses a comprehensive suite of automated tools to maintain code quality:
- Formatting: Ruff formatter
- Linting: Ruff linter
- Type Checking:
tystatic type checker - Testing: Pytest with coverage
Running All Checks¶
Run all quality checks with a single command:
This command runs all checks in sequence:
- Format → Auto-fixes code style
- Lint → Checks for code issues
- Typecheck → Verifies type annotations
- Test → Runs test suite with coverage
If all checks pass, you'll see:
Individual Checks¶
Format Code¶
Automatically formats all Python files using Ruff.
What it fixes:
- Line length (max 80 characters)
- Import ordering
- Trailing whitespace
- Quote normalization
Lint Code¶
Checks for code quality issues without modifying files.
What it checks:
- Unused imports
- Undefined variables
- Style violations
- Complexity issues
Type Check¶
Validates all type annotations using ty.
Requirements:
- 100% type hint coverage
- No type errors
- Proper return types
Run Tests¶
Runs the full test suite with coverage reporting.
Requirements:
- All tests pass
- Coverage ≥ 95%
Pre-commit Hooks¶
Install pre-commit hooks to run checks automatically before every commit:
After installation, hooks run automatically:
To run hooks manually on all files:
CI Integration¶
All quality checks run automatically on every push via GitHub Actions:
# .github/workflows/ci.yml
- name: Run all quality checks
run: just check
- name: Verify coverage threshold
run: coverage report --fail-under=95
Pull requests cannot be merged until all checks pass ✅
Quality Standards¶
The project maintains strict quality standards:
| Check | Requirement | Tool |
|---|---|---|
| Formatting | 100% compliant | Ruff |
| Linting | 0 violations | Ruff |
| Type Hints | 100% coverage | ty |
| Tests | ≥95% coverage | Pytest |
| Line Length | ≤80 chars | Ruff |
Quick Reference¶
| Task | Command |
|---|---|
| Run all checks | just check |
| Format code | just format |
| Lint code | just lint |
| Type check | just typecheck |
| Run tests | just test |
| Install hooks | just pi |
| Run hooks | just pr |
Troubleshooting¶
Format Conflicts¶
If Ruff format changes conflict with manual edits:
Type Errors¶
If type checking fails:
- Check return types include
| Nonewhere needed - Add type parameters to generics:
list[User] - Use
from __future__ import annotationsfor forward refs
Coverage Below Threshold¶
If coverage drops below 95%:
Find untested lines and add tests.
See Also¶
- Testing Guide — Writing and running tests
- Troubleshooting — Common quality check issues
- Contributing Guide — Development workflow