Interview Prep/Python for DevOps/Testing, services & metrics

What do `ruff` and `mypy` do, and why run them in CI?

BeginnerConceptTesting, services & metrics
Answer
  • ruff is a very fast linter and formatter (replacing flake8, isort, pyupgrade, black-style formatting and many pylint rules). It catches unused imports, undefined names, mutable defaults, bare excepts, f-strings in logging and more.
  • mypy is a static type checker that catches wrong types, None handling bugs and misspelled attributes.
ruff check . && ruff format --check . && mypy src

They run in seconds and catch bugs that otherwise surface only at runtime, often in production. We also run them as pre-commit hooks.

All Python for DevOps questions Roadmap: Python for automation

More on Testing, services & metrics