30 lines | 1.3 KB

python-pep8

General Python style rules from PEP 8, plus PEP 257 docstring conventions, for AI coding agents.

npx rulepack add python-pep8

What it covers

  • Layout — 4-space indent, 79-column limit, two/one blank-line spacing, breaking before binary operators.
  • Namingsnake_case functions/variables, CapWords classes, UPPER_CASE constants, underscore conventions.
  • Imports — one per line, grouped stdlib / third-party / local, no wildcards.
  • Whitespace — rules for brackets, commas, operators, and annotated defaults.
  • Docstrings & comments — PEP 257 triple-double-quote docstrings, imperative mood, block/inline comment style.
  • Comparisonsis/is not for None, isinstance, truthiness for empty sequences.
  • Type hints — brief PEP 484 notes (optional, static-only).

This is general Python style. For the FastAPI framework, see the python-fastapi pack — they complement each other. PEP 8 itself recommends enforcing layout with a formatter (black / ruff).

Source

License

MIT