Python Anti-Patterns Checklist
A reference checklist of common mistakes and anti-patterns in Python code. Review this before finalizing implementations to catch issues early.
When to Use This Skill
- Reviewing code before merge
- Debugging mysterious issues
- Teaching or learning Python best practices
- Establishing team coding standards
- Refactoring legacy code
Note: This skill focuses on what to avoid. For guidance on positive patterns and architecture, see the python-design-patterns skill.
Infrastructure Anti-Patterns
Scattered Timeout/Retry Logic
Fix: Centralize in decorators or client wrappers.
Double Retry
Fix: Retry at one layer only. Know your infrastructure's retry behavior.
Hard-Coded Configuration
Fix: Use environment variables with typed settings.
Architecture Anti-Patterns
Exposed Internal Types
Fix: Use DTOs/response models.
Mixed I/O and Business Logic
Fix: Repository pattern. Keep business logic pure.
Error Handling Anti-Patterns
Bare Exception Handling
Fix: Catch specific exceptions. Log or handle appropriately.
Ignored Partial Failures
Fix: Capture both successes and failures.
Missing Input Validation
Fix: Validate early at API boundaries.
Resource Anti-Patterns
Unclosed Resources
Fix: Use context managers.
Blocking in Async
Fix: Use async-native libraries.
Type Safety Anti-Patterns
Missing Type Hints
Fix: Annotate all public functions.
Untyped Collections
Fix: Use type parameters.
Testing Anti-Patterns
Only Testing Happy Paths
Fix: Test error conditions and edge cases.
Over-Mocking
Fix: Use integration tests for critical paths. Mock only external services.
Quick Review Checklist
Before finalizing code, verify:
- No scattered timeout/retry logic (centralized)
- No double retry (app + infrastructure)
- No hard-coded configuration or secrets
- No exposed internal types (ORM models, protobufs)
- No mixed I/O and business logic
- No bare
except Exception: pass - No ignored partial failures in batches
- No missing input validation
- No unclosed resources (using context managers)
- No blocking calls in async code
- All public functions have type hints
- Collections have type parameters
- Error paths are tested
- Edge cases are covered




