name: python-general description: "Lightweight guidance for writing and modifying Python. Use for Python changes that may involve logging, modern typing, exception and context-manager design, async practices, or choosing effective standard-library APIs."¶
Python General¶
Follow the project's Python version, configuration, and established patterns. Prefer current syntax and standard-library APIs supported by that version, keep behavior explicit, and validate changes with the narrowest relevant check.
Load only the concrete reference relevant to the edit:
- Logger ownership, configuration, structured context, and async-safe emission: Python logging
- Current annotation syntax, narrowing, generics, and checker discipline: Python typing
- Exception boundaries, causal chains, translation, and recovery: error handling
- Resource ownership, reusable cleanup, and sync or async context protocols: context managers
- Structured concurrency, cancellation, timeouts, blocking work, and task ownership: modern async
- Frequently overlooked modules and preferred standard-library selections: standard library
- Clear code structure, unambiguous names, and comments and docstrings that add information: human readability