Python (Strict)
Use this skill when the user wants strict, explicit Python code with low ambiguity and fail-fast behavior.
Core Rules
- Put all imports at the top of the file.
- Never use
getattrorhasattr. - Never use
isinstancetype checks. - Do not introduce implicit defaults for required data paths.
- Avoid unnecessary
try/except; only keep exception handling for a clearly required fallback or boundary.
Implementation Pattern
- Validate required keys/attributes explicitly.
- Use direct indexing/attribute access for required fields.
- For optional branches, use explicit
if "key" in objchecks. - Prefer fail-fast errors over silent fallback behavior.
- Keep control flow straightforward; avoid defensive swallowing of errors.
Review Checklist
- Imports are module-level and grouped at file top.
- No reflective access helpers (
getattr,hasattr). - No runtime type filtering with
isinstance. - No hidden default values for required fields.
- Exception blocks are minimal and justified.
- Errors are explicit and actionable.
References
references/patterns.mdfor quick before/after rewrite patterns.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.