Python 3.14+ Expert Best Practices
Simple, pragmatic, opinionated. Only what matters for writing production-grade python code.
When to Apply
Reference these guidelines when:
- Writing Python functions, classes, or modules
- Reviewing Python code for error handling issues
- Refactoring existing Python codebases
- Implementing data validation and API boundaries
- Optimizing error detection and debugging patterns
Rule Categories by Priority
Quick Reference
dict-required-keys- Used[key]for required dictionary keys to fail fast with KeyErrorno-mutable-defaults- No mutable defaults in function/method parametersoperators-return-notimplemented- Return NotImplemented for unsupported operand types and design + vs += intentionallyno-generic-except- Avoid generic except clauses to prevent hiding unexpected errorslistcomp-no-side-effects- List comprehensions must produce a value you use (no side-effect listcomps)no-inline-imports- Place all import statements at the top of the fileavoid-explanatory-comments- Avoid unnecessary comments for self-documenting codeunnecessary-else-blocks- Avoid unnecessary else blocks after return/break/continue statements
How to Use
Read individual rule files for detailed explanations and code examples:
Each rule file contains:
- Brief explanation of why it matters
- When to use and when not to use the pattern
- Implementation requirements
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references


