Python Best-Practices Skill
Idiomatic refactors and audits - an Agent Skill for Python 3.14 code quality.
Search across all documentation pages
Idiomatic refactors and audits - an Agent Skill for Python 3.14 code quality.
Audits a package for idiomatic Python: ruff lint/format fixes, pathlib over os.path, dataclasses vs dicts, exception chaining, logging over print, security smells (eval, pickle, SQL f-strings), and produces tiered refactor PR plan.
| Input | Why |
|---|---|
| Target path | src/billing/ scope |
| Risk tolerance | auto-fix safe vs manual review |
| Test presence | required before behavior-changing refactors |
| Style config | ruff.toml / pyproject tool section |
| Team rules | link to python-rules section ADRs |
ruff check --fix and ruff format diff summaryraise ... from exc - preserve tracebacks.None sentinel.% or .format in new edits.uv run ruff check src/ --fix
uv run ruff format src/
uv run pytest -q
uv run mypy src/ # optional gate# before
def add_item(item, bucket=[]):
bucket.append(item)
return bucket
# after
def add_item(item, bucket=None):
if bucket is None:
bucket = []
bucket.append(item)
return bucketSafe fixes only in first PR - unsafe rules need human review per file.
ruff format replaces Black when enabled - one formatter per repo.
Stack versions: This page was written for Python 3.14.0 (stable 3.14, maintenance 3.13), 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 16, 2026