Skip to content

Code Quality

Overview

The project maintains high code quality standards through automated tools and pre-commit hooks.

Code Style

Line Length

79 characters maximum (enforced by Ruff)

Formatting

# Format code
uvx ruff format

# Check formatting
uvx ruff check --config=pyproject.toml

Type Hints

Required on all functions (enforced by mypy --strict):

def get_author(author_id: int) -> Author | None:
    """Get author by ID."""
    pass

Docstrings

Required on all public functions, classes, and methods (80% coverage minimum):

def create_author(name: str) -> Author:
    """
    Create a new author.

    Args:
        name: Author's full name

    Returns:
        Created author instance

    Raises:
        ValueError: If name is empty
    """
    pass

Linting

Ruff

# Check all files
make ruff-check

# Auto-fix issues
uvx ruff check --fix

Mypy

# Type check
uvx mypy app/

Interrogate

# Check docstring coverage
uvx interrogate app/

Security

Bandit

# SAST scanning
make bandit-scan

Skjold

# Dependency vulnerability scanning
make skjold-scan

Dead Code Detection

# Find unused code
make dead-code-scan

Spell Checking

# Check typos
uvx typos

Pre-commit Hooks

All checks run automatically on commit:

# Install hooks
pre-commit install

# Run manually
pre-commit run --all-files