Install the skill above, then run this in your AI tool:
/python-anti-patterns <your description>
About
A reference checklist of common mistakes and anti-patterns in Python code. Review this before finalizing implementations to catch issues early.
Source
What gets added to your project
Preview every file this package writes on install before you run the command above.
Summary
Use this skill when reviewing Python code for common anti-patterns to avoid. Use as a checklist when reviewing code, before finalizing implementations, or when debugging issues that might stem from known bad practices.
Skill instructions
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.
# BAD: Leaking ORM model to API@app.get("/users/{id}")defget_user(id: str) -> UserModel: # SQLAlchemy modelreturn db.query(UserModel).get(id)
Fix: Use DTOs/response models.
python
# GOOD@app.get("/users/{id}")defget_user(id: str) -> UserResponse:
user = db.query(UserModel).get(id)
return UserResponse.from_orm(user)
Mixed I/O and Business Logic
python
# BAD: SQL embedded in business logicdefcalculate_discount(user_id: str) -> float:
user = db.query("SELECT * FROM users WHERE id = ?", user_id)
orders = db.query("SELECT * FROM orders WHERE user_id = ?", user_id)
# Business logic mixed with data accessiflen(orders) > 10:
return0.15return0.0
Fix: Repository pattern. Keep business logic pure.
python
# GOODdefcalculate_discount(user: User, orders: list[Order]) -> float:
# Pure business logic, easily testableiflen(orders) > 10:
return0.15return0.0
Fix: Catch specific exceptions. Log or handle appropriately.
python
# GOODtry:
process()
except ConnectionError as e:
logger.warning("Connection failed, will retry", error=str(e))
raiseexcept ValueError as e:
logger.error("Invalid input", error=str(e))
raise BadRequestError(str(e))
Ignored Partial Failures
python
# BAD: Stops on first errordefprocess_batch(items):
results = []
for item in items:
result = process(item) # Raises on error - batch aborted
results.append(result)
return results
Fix: Capture both successes and failures.
python
# GOODdefprocess_batch(items) -> BatchResult:
succeeded = {}
failed = {}
for idx, item inenumerate(items):
try:
succeeded[idx] = process(item)
except Exception as e:
failed[idx] = e
return BatchResult(succeeded, failed)
Missing Input Validation
python
# BAD: No validationdefcreate_user(data: dict):
return User(**data) # Crashes deep in code on bad input
Add this badge to a GitHub README so readers can open the package page and install the same version.
[](https://www.aipm-registry.com/skills/wshobson/python-anti-patterns/1.0.0?utm_source=github&utm_medium=readme&utm_campaign=package_badge)
This imported publisher has not claimed its AIPM account. A connected account confirms account control, but it does not guarantee that a package is safe.
AI assistant context
What this skill is for
@wshobson/python-anti-patterns@1.0.0 is an AIPM skill package for All tools. Use it when a project needs the reusable AI behavior described as: Use this skill when reviewing Python code for common anti-patterns to avoid. Use as a checklist when reviewing code, before finalizing implementations, or when debugging issues that might stem from known bad practices.
Run aipm add @wshobson/python-anti-patterns@1.0.0 in a project that has AIPM initialized.
Supported tools
@wshobson/python-anti-patterns@1.0.0 supports All tools.
Before installing
AIPM skills can add files to your project. Review the package name, target, description, license, and publisher before installing. Use a clean branch when trying a new skill.