roddsrod/python-rules icon
public
Published on 4/29/2025
roddsrod/python-rules

Python Rules

Rules

Build & Development Commands - Use python -m venv .venv to create isolated environments unless the project uses Poetry or Conda. - Avoid installing packages globally. - Use requirements.txt or pyproject.toml for dependencies.

Testing Guidelines - Prefer pytest for test automation unless the project is based on unittest. - Use fixtures or mocks for external systems (e.g., DBs, APIs). - Follow Arrange-Act-Assert in tests.

Code Style & Guidelines - Follow PEP8 formatting; enforce with black, ruff, or flake8. - Use type hints for all public functions. - Prefer comprehensions over loops for simple list/tuple generation. - Avoid bare except: clauses — catch specific exceptions.

Documentation Guidelines - Use docstrings for all public functions and classes (Google or reST style). - Document side effects, exceptions, and return types. - Include examples for complex functions or modules.