python-expert
Python gotchas and decision criteria. Covers async pitfalls, FastAPI/Django patterns, and type hint traps.
Works with
---
name: python-expert
description: Python gotchas and decision criteria. Covers async pitfalls, FastAPI/Django patterns, and type hint traps.
license: MIT
---
> **AI-consumed reference.** Optimized for Claude to read during execution.
> Human-readable explanation: see [docs/architecture/HIERARCHICAL_PLANNING.md](../../../docs/architecture/HIERARCHICAL_PLANNING.md)
> or [docs/getting-started/](../../../docs/getting-started/) depending on topic.
# Python Expert — Gotchas & Decisions
Use Context7 for FastAPI/Django/Flask docs.
## Key Decisions
```toon
decisions[4]{choice,use_when}:
FastAPI vs Django vs Flask,"FastAPI: async APIs + auto-docs. Django: full-featured + ORM + admin. Flask: minimal/micro"
Pydantic vs dataclass,"Pydantic for validation/serialization (API boundaries). dataclass for internal structs"
SQLAlchemy vs Django ORM,"SQLAlchemy: standalone/FastAPI. Django ORM: Django projects only"
sync vs async,"async for I/O-bound (HTTP/DB). sync for CPU-bound. Don't mix blocking calls in async"
```
## Gotchas
- Mutable default args: `def f(items=[])` shares list across calls — use `def f(items=None): items = items or []`
- `asyncio.run()` creates new event loop — can't nest. Use `await` inside existing async context
- FastAPI `Depends()`: new instance per request by default. Use `@lru_cache` for singletons
- Django N+1: use `select_related` (FK/OneToOne) and `prefetch_related` (M2M/reverse FK)
- `isinstance(x, int)` catches `bool` too — `bool` is subclass of `int`. Check `type(x) is int` if needed
- Type hints are NOT enforced at runtime — use Pydantic or `beartype` for runtime validation
- `dict.get('key')` returns `None` silently — use `dict['key']` when key must exist
- `requirements.txt` vs `pyproject.toml`: prefer pyproject.toml (PEP 621) for modern projects
- `with` statement for resource cleanup (files, DB connections) — never rely on `__del__`More Backend Frameworks skills
git-guardrails-claude-code
mattpocock/skills
Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
azure-compute
microsoft/azure-skills
Azure VM/VMSS router. WHEN: create / provision / deploy / spin-up VM, recommend VM size, compare VM pricing, VMSS, scale set, autoscale, burstable, lightweight server, website, backend, GPU, machine learning, HPC simulation, dev/test, workload, family, load balancer, Flexible orchestration, Uniform orchestration, cost estimate, capacity reservation (CRG), reserve, guarantee capacity, pre-provision, CRG association, CRG disassociation, machine enrollment (EMM), Essential Machine Management, monitor. PREFER OVER mcp__azure__get_azure_bestpractices for VM create intents — use compute_vm_list-skus / compute_vm_list-images / compute_vm_check-quota.
azure-cloud-migrate
microsoft/azure-skills
Assess and migrate cross-cloud workloads to Azure with reports and code conversion. Supports Lambda→Functions, Beanstalk/Heroku/App Engine→App Service, Fargate/Kubernetes/Cloud Run/Spring Boot→Container Apps. WHEN: migrate Lambda to Functions, AWS to Azure, migrate Beanstalk, migrate Heroku, migrate App Engine, Cloud Run migration, Fargate to ACA, ECS/Kubernetes/GKE/EKS to Container Apps, Spring Boot to Container Apps, cross-cloud migration.

