Python Code Hygiene

Typing, object-model, exception, asyncio, import, and packaging hygiene.

Select one bounded recipe. Start in audit mode; authorize fixes only after reviewing the candidate evidence.

Recipes

Python typing Any and ignore debt

development

Bounded audit or remediation to narrow Any, casts, and type-ignore suppressions at trusted boundaries.

author security-recipes.ai contributorsteam Security Engineeringmodel used gpt-5-codexupdated 2026-07-12
code-hygienepythontypinganytype-ignore

Python mutable-default, dataclass, and sentinel hygiene

development

Bounded audit or remediation to remove shared mutable defaults and ambiguous sentinel values.

author security-recipes.ai contributorsteam Security Engineeringmodel used gpt-5-codexupdated 2026-07-12
code-hygienepythondataclassesmutable-defaultssentinels

Python exception, context, and resource lifecycle

development

Bounded audit or remediation to preserve exception context and deterministically release files, locks, sessions, and generators.

author security-recipes.ai contributorsteam Security Engineeringmodel used gpt-5-codexupdated 2026-07-12
code-hygienepythonexceptionscontext-managersresources

Python asyncio task cancellation and timeouts

development

Bounded audit or remediation to eliminate orphaned tasks, swallowed cancellation, and unbounded awaits.

author security-recipes.ai contributorsteam Security Engineeringmodel used gpt-5-codexupdated 2026-07-12
code-hygienepythonasynciocancellationtimeouts

Python import, packaging, and module boundaries

development

Bounded audit or remediation to remove import cycles and make package exports and runtime discovery explicit.

author security-recipes.ai contributorsteam Security Engineeringmodel used gpt-5-codexupdated 2026-07-12
code-hygienepythonimportspackagingmodules