This document describes the code quality tools and linting setup for the Performance Dashboard project.
The project uses a comprehensive set of tools to ensure code quality, consistency, and security:
- Ruff: Fast Python linter (replaces flake8, pylint, and more)
- Black: Code formatter
- isort: Import sorting
- mypy: Static type checking
- pytest: Testing framework with coverage
- pre-commit: Git hooks for automated checks
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pre-commit install# Format code automatically
make format
# Run all linting checks
make lint
# Run type checking
make type-check
# Run all CI checks locally
make ci-localRuff is configured in pyproject.toml and includes:
- Enabled rules: E, W, F, I, B, C4, UP, ARG, C90, T20, SIM, ICN
- Line length: 88 characters (matches Black)
- Max complexity: 12
Common rules:
E501: Line too long (handled by Black)F401: Unused importsB008: Function calls in argument defaultsI001: Import sorting
Black is the primary code formatter with:
- Line length: 88 characters
- Target versions: Python 3.9+
- Style: PEP 8 compliant
Type checking configuration:
- Python version: 3.9+
- Missing imports: Ignored for external libraries
- Untyped defs: Allowed (can be made stricter)
The following hooks run on every commit:
- Trailing whitespace removal
- End-of-file fixer
- YAML/JSON validation
- Ruff linting and formatting
- mypy type checking
- Bandit security scanning
- pydocstyle docstring checking
- Prettier formatting (YAML/Markdown)
The CI/CD pipeline is defined in .github/workflows/ci.yml and runs automatically on:
- Push to
mainordevelopbranches - Pull requests targeting
mainordevelop - Manual trigger via workflow_dispatch
The workflow includes the following parallel jobs:
Runs all pre-commit hooks to validate code quality:
- Trailing whitespace removal
- End of file fixes
- YAML/TOML validation
- Ruff linting with auto-fixes
- Ruff formatting (Python code formatter)
- mypy type checking
- Bandit security scanning
- pydocstyle docstring validation (Google convention)
- Prettier for YAML/Markdown formatting
Status: Required - PR cannot merge if this fails
Runs mypy static type checking:
- Generates JUnit XML report
- Uploads
mypy-report.xmlas artifact - Status: Advisory only (continues on error)
Runs the test suite with coverage reporting:
- Executes pytest with coverage
- Generates coverage reports (XML, HTML, terminal)
- Uploads coverage to Codecov (if configured)
- Uploads coverage artifacts for review
- Status: Required - PR cannot merge if tests fail
Validates Python docstrings:
- Checks Google-style docstring format
- Ensures all public modules/functions documented
- Status: Advisory only (continues on error)
- Navigate to the Actions tab in the GitHub repository
- Select the workflow run to view job details
- Click on individual jobs to see logs and artifacts
- Download artifacts (test reports, coverage) from the job summary page
For specific lines:
# ruff: noqa: E501
very_long_line_that_exceeds_the_limit_but_is_necessary_for_some_reason()
# mypy: ignore
problematic_type_annotation = some_complex_function()For entire files:
# ruff: noqaEdit pyproject.toml:
[tool.ruff]
ignore = [
"E501", # line too long
"T201", # print statements
]
[tool.ruff.per-file-ignores]
"tests/*" = ["T201"] # Allow prints in tests