Python quality gate workflow
Use this skill when:
- •You changed Python code and want it to pass formatting/lint/type/tests.
- •You're preparing a PR/release and need a consistent "done" checklist.
Steps
- •Locate project tooling config
- •Check for
pyproject.toml,ruff.toml,setup.cfg,mypy.ini,pytest.ini. - •Follow repo config over default tool flags.
- •Format
- •Run:
python -m black . - •If Black isn't installed, propose adding it to the dev environment and explain how to install.
- •Lint
- •Run:
python -m ruff check . --fix - •If Ruff isn't installed, propose adding it and re-run.
- •Types (only if configured/expected)
- •If
mypy.inior mypy config exists, run:python -m mypy . - •Fix type errors by improving annotations (avoid weakening to
Anyunless unavoidable).
- •Tests
- •Run:
python -m pytest -q - •If failures: fix implementation first; only adjust tests if the test is wrong or spec changed.
- •Exit criteria
- •No formatting diffs from Black.
- •Ruff clean (or only allowed ignores).
- •Mypy clean (if used).
- •Pytest passing.
Common fixes
- •Replace
== Nonewithis None. - •Prefer
Pathlibover manual path string ops when appropriate. - •Tighten return types and avoid ambiguous
Optionalbehavior.