17 lines | 1.4 KB

AGENTS.md — Python (PEP 8)

  • Indent with 4 spaces, never tabs. No trailing whitespace.
  • Keep lines to 79 chars (72 for comments/docstrings); up to 99 only by team agreement.
  • Two blank lines between top-level defs/classes; one between methods.
  • snake_case for functions/variables/methods/modules; CapWords for classes (exceptions end in Error); UPPER_CASE for constants.
  • _leading_underscore = non-public. Never use l, O, or I as names. First args are self / cls.
  • One import per line; group stdlib / third-party / local with a blank line between; no wildcard imports.
  • No spaces inside ()[]{} or before ,;:; single spaces around binary operators; no spaces around = in kwargs unless the param is annotated.
  • Break long lines before the operator.
  • Docstrings ("""...""") on every public module/class/function/method; imperative mood, period; closing """ on its own line for multi-line.
  • Compare to None with is/is not; use isinstance(...); rely on truthiness (if not seq:).
  • No bare except:; catch specific exceptions, keep try blocks small.
  • Use def, not a lambda bound to a name.
  • Type hints (x: int -> str) are optional and static-only; use Optional[T] / T | None.
  • Run ruff / black to enforce layout — PEP 8 values readability and module-level consistency over rigid rule-following.