18 lines | 1.1 KB

description: Python style per PEP 8 (+ PEP 257 docstrings) globs: ["**/*.py"] alwaysApply: true

  • 4-space indent, no tabs. Lines ≤ 79 chars (72 for comments/docstrings).
  • Two blank lines around top-level defs/classes; one between methods.
  • snake_case functions/variables; CapWords classes; UPPER_CASE constants. Exceptions end in Error.
  • _leading_underscore for non-public. First args self / cls. Never name things l, O, I.
  • One import per line, grouped stdlib / third-party / local with blank lines; no wildcard imports.
  • No spaces inside brackets or before ,;:; single spaces around binary operators; break long lines before the operator.
  • Docstrings ("""...""") on public modules/classes/functions/methods; imperative mood, end with a period.
  • Compare to None with is/is not; use isinstance(...); prefer truthiness (if not seq:).
  • No bare except:; use def over a named lambda.
  • Type hints optional, static-only: def f(x: int) -> str:, Optional[T] / T | None.
  • Let ruff / black enforce layout; value module-level consistency over rigid compliance.