- Type hints everywhere
- Short focused functions; high-level first, helpers later
- f-strings, double quotes
m- Relative imports inside the package, absolute otherwise. Only one-level relative imports (
from .core, notfrom ..core) - Newspaper-style: public API at the top, private helpers below
- Composition over inheritance
- Code should be self-explanatory; no comments by default
- Only add docstrings for public API methods
- When docstrings are needed, use multi-line format:
""" Description here. """
- Inline comments (
#) only for the most complex logic
- One behavior per test
- AAA pattern (Arrange -> Act -> Assert)
- Naming:
test__subject__when_condition__then_expected_result conftest.pyonly for shared fixtures; otherwise keep fixtures in local test files
Pattern: <type>: <description>
Types:
feat— new featurefix— bug fixrefactor— code restructuring without behavior changetest— adding/updating testsdocs— documentation changeschore— maintenance, dependencies, configs
Examples:
feat: add streaming support for deadline propagationfix: handle zero timeout in TimeoutSourcerefactor: extract source lifecycle to SourceSettest: add nested scope cancellation tests
Run formatting before every commit.
- Be concise; avoid over-explaining
- Use English
- Brief plan before starting
- TDD when defining new behavior: interface -> tests -> implementation
- If docs and code are inconsistent — highlight and ask, or fix immediately