Skip to content

Code Quality

Code quality is the measure of how reliable, efficient, readable, and maintainable software code is, encompassing its ability to function correctly, be understood, modified, and extended easily by developers while meeting user needs and security standards. It's about more than just being bug-free; high-quality code is well-structured, performant, testable, and adheres to best practices, making it a valuable asset rather than a liability.

Pre-Commit

pre-commit: a framework for managing and maintaining multi-language pre-commit hooks. prek: an alternative to pre-commit, re-engineered in Rust.

pre-commit install --allow-missing-config
pre-commit autoupdate # Update hooks
pre-commit run --all-files # All files
pre-commit run ruff-check # Specific hook

NOTE: Pre-commit hooks run all checks automatically when enabled properly.

Ruff

ruff: an extremely fast Python linter and code formatter, written in Rust.

uv run ruff check src/ # Check code
uv run ruff check --fix # Fix issues
uv run ruff format # Format code

NOTE: ruff is not fully implemented yet; do not run it.

Ty

ty: an extremely fast Python type checker and language server, written in Rust.

uv run ty check src/ # Check code

NOTE: ty is not fully implemented yet; do not run it.

Code Style Guidelines

Python Formatting

  • Maximum line length: 120 characters
  • Use double quotes for strings
  • Add trailing commas in multi-line data structures
  • Follow PEP 8 conventions

Docstrings

Use docstrings for:

  • Modules
  • Classes
  • Public functions and methods

Follow Google or NumPy docstring style conventions.

CI/CD Integration

Code quality checks run automatically in CI/CD pipelines:

  • On pull request creation
  • On commits to the main branch
  • Before deployment

All checks must pass before code can be merged.