Python Code Hygiene
Typing, object-model, exception, asyncio, import, and packaging hygiene.
Choose a focused Python recipe
This collection contains 5 bounded Python workflows. Choose the recipe whose objective matches the repository evidence instead of combining unrelated cleanup into one run.
- Python typing Any and ignore debt: Use it to narrow Any, casts, and type-ignore suppressions at trusted boundaries.
- Python mutable-default, dataclass, and sentinel hygiene: Use it to remove shared mutable defaults and ambiguous sentinel values.
- Python exception, context, and resource lifecycle: Use it to preserve exception context and deterministically release files, locks, sessions, and generators.
- Python asyncio task cancellation and timeouts: Use it to eliminate orphaned tasks, swallowed cancellation, and unbounded awaits.
- Python import, packaging, and module boundaries: Use it to remove import cycles and make package exports and runtime discovery explicit.
How to use this collection
Read the repository’s configured runtime, compiler, framework, analyzer, and test commands before selecting a workflow. Start in audit mode, record file and symbol evidence, and authorize a fix only after the candidate scope is reviewable. Preserve supported versions, public behavior, and existing tool configuration.
If the evidence is a named CVE, scanner finding, exposed secret, authorization flaw, or injection path, use the focused vulnerability-remediation playbook instead of a code-hygiene recipe. Stop when the safe result requires an owner decision about architecture, compatibility, production data, or deployment state.
Full recipe list
Python typing Any and ignore debt
developmentPython typing Any and ignore debt: Narrow Any, casts, and type-ignore suppressions at trusted boundaries.
Python mutable-default, dataclass, and sentinel hygiene
developmentPython mutable-default, dataclass, and sentinel hygiene: Remove shared mutable defaults and ambiguous sentinel values.
Python exception, context, and resource lifecycle
developmentPython exception, context, and resource lifecycle: Preserve exception context and deterministically release files, locks, sessions, and generators.
Python asyncio task cancellation and timeouts
developmentPython asyncio task cancellation and timeouts: Eliminate orphaned tasks, swallowed cancellation, and unbounded awaits.
Python import, packaging, and module boundaries
developmentPython import, packaging, and module boundaries: Remove import cycles and make package exports and runtime discovery explicit.