Linting & Formatting Best Practices
A low-friction lint and format setup that catches real bugs without slowing developers down.
Search across all documentation pages
A low-friction lint and format setup that catches real bugs without slowing developers down.
pyproject.toml. No scattered .flake8, setup.cfg, or .isort.cfg.target-version = "py314". Rules match your Python version.tests/** allows assert; migrations/** excluded.select = ["ALL"] on day one. Add rules incrementally to avoid alert fatigue..vscode/settings.json for the team.pre-commit install in README bootstrap steps.ruff check --fix before pushing. Catches what pre-commit missed.ruff check . and ruff format --check . in CI. Both are required checks.rev. Local and CI stay in sync.continue-on-error..ruff_cache, .mypy_cache keyed on lockfile.noqa and type: ignore needs a comment. Explains why the rule is suppressed.ruff check + ruff format + CI. Add mypy when the codebase has type hints.
Map flake8 plugins to ruff rule codes. Enable equivalent sets. Remove flake8 from CI.
Exclude it. Add paths to exclude in ruff config.
check_untyped_defs first. Move to strict module by module.
CI must still run the same checks. pre-commit saves CI round-trips.
Enable rules as warnings first. Fix per-module. Flip to errors when clean.
ruff format for new projects. Equivalent output, faster execution.
Yes, with ruff format notebook.ipynb. Exclude output cells if noisy.
One pyproject.toml at root with src paths, or per-package configs with extend.
Enable S (bandit) rules for any code handling user input, secrets, or SQL.
Stack versions: This page was written for Python 3.14.0, FastAPI 0.115+, Django 5.2, Flask 3.1, Pydantic 2, PyTorch 2.6+, pandas 2.2+, Polars 1.x, ruff 0.9+, and uv 0.6+.
Reviewed by Chris St. John·Last updated Jul 19, 2026