Skip to content

Instantly share code, notes, and snippets.

@franccesco
Last active July 12, 2025 19:25
Show Gist options
  • Save franccesco/0d7789225128b58ef362bb689f845017 to your computer and use it in GitHub Desktop.
Save franccesco/0d7789225128b58ef362bb689f845017 to your computer and use it in GitHub Desktop.
Some ruff / pyright rules to make sure AI write quality code
[tool.ruff.lint]
preview = true
select = [
"E", # pycodestyle — hard PEP 8 violations (indentation, spacing, etc.).
"W", # pycodestyle warnings — softer style nits you still want fixed.
"F", # pyflakes — real code errors: undefined names, unused vars & imports.
"I", # isort — keep your import blocks deterministically sorted/grouped.
"B", # bugbear — likely bugs and nasty edge-cases (mutable defaults, etc.).
"C4", # comprehensions — suggest faster/cleaner list- & dict-comps.
"UP", # pyupgrade — auto-rewrite code to the newest-supported Python syntax.
"C901", # mccabe — flag functions whose cyclomatic complexity balloons.
"SIM", # simplify — call out over-engineered constructs; prefer the obvious one-liner.
"N", # pep8-naming — enforce PEP 8 names for classes, funcs, vars, etc.
"RUF", # Ruff-native extras — Ruff-only correctness/perf rules (a la "unicorn").
"FAST", # fastapi — idiomatic FastAPI patterns and anti-pattern detection.
"DOC", # pydoclint — Google/Numpy docstring section order & completeness.
"D", # pydocstyle — PEP 257 docstring formatting conformance.
"ARG", # unused-arguments — catch never-used *args/**kwargs/params.
"PERF", # perflint — flag obvious performance foot-guns (e.g., `list()` in loops).
]
ignore = ["D203", "D212", "D213"]
[tool.ruff.lint.mccabe]
# Maximum complexity allowed (default is 10)
max-complexity = 10
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
[tool.pyright]
typeCheckingMode = "strict"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment