trove-python
/trove-python
Python/FastAPI coding conventions and best practices. Auto-activates when working with Python files. Covers async patterns, type hints, SQLAlchemy, Pydantic, logging, and error handling. Use when: python conventions; fastapi patterns; async python; pydantic models.
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 2
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 08.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- SKILL.md zawiera komentarze HTML (2). Nie widać ich w podglądzie Markdown, a model je czyta.
What it does and when to use it
Python/FastAPI coding conventions and best practices. Auto-activates when working with Python files. Covers async patterns, type hints, SQLAlchemy, Pydantic, logging, and error handling. Use when: python conventions; fastapi patterns; async python; pydantic models.
Original author description
Python/FastAPI coding conventions and best practices. Auto-activates when working with Python files. Covers async patterns, type hints, SQLAlchemy, Pydantic, logging, and error handling. Use when: python conventions; fastapi patterns; async python; pydantic models.
How it works
- Session Init
- Imports
- Type Hints
- Async Patterns (CRITICAL)
- Logging
- SQLAlchemy Async
- Error Handling
- Pydantic Models
- AI Gotchas
SKILL.md preview
---
name: trove-python
description: "Python/FastAPI coding conventions and best practices. Auto-activates when working with Python files. Covers async patterns, type hints, SQLAlchemy, Pydantic, logging, and error handling. Use when: python conventions; fastapi patterns; async python; pydantic models."
---
<!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly -->
<!-- Regenerate: bun run build:skills -->
## Session Init
This skill ships Trove conventions. Prefer existing project patterns over generic best practices when they conflict.
# Python / FastAPI Conventions
## Imports
- **Top-level imports only** — never inline imports inside functions
- Organization: stdlib → third-party → local (isort-compatible)
- Use `from __future__ import annotations` when needed for forward refs
## Type Hints
- All function signatures must have type hints (params + return)
- Use `from typing import` for complex types (`Optional`, `Union`, etc.)
- Pydantic models for all request/response schemas
- Prefer `X | None` over `Optional[X]` (Python 3.10+)
## Async Patterns (CRITICAL)
Never call blocking I/O in async functions:
```python
# BAD — blocks the event loop
async def get_user(user_id: str):
response = requests.get(f"/users/{user_id}") # BLOCKING!
time.sleep(1) # BLOCKING!
# GOOD — non-blocking
async def get_user(user_id: str):
async with httpx.AsyncClient() as client:
response = await client.get(f"/users/{user_id}")
await asyncio.sleep(1)
```
- Use `httpx.AsyncClient` for HTTP (not `requests`)
- Use `asyncio.sleep` for delays (not `time.sleep`)
- Use `async with` for context managers (DB sessions, HTTP clients)
## Logging
```python
# INFO/DEBUG — f-strings are fine (fast path, no Sentry indexing needed)
logger.info(f"Processing user {user_id}")
# WARNING/ERROR — static message + extra dict (enables Sentry grouping)
logger.warning("Payment failed", extra={"user_id": user_id, "amount": amount})
# EXCEPTION — use in except blocks (auto-captures stack trace)
try:
await process()
except Exception:
logger.exception("Processing failed", extra={"user_id": user_id})
```
Never use `sentry_sdk.capture_exception()` — use `logger.exception()` instead.
## SQLAlchemy Async
```python
# Always use async session context manager
async with get_async_session() as session:
result = await session.execute(select(User).where(User.id == user_id))
user = result.scalar_one_or_none()
# Eager loading to avoid N+1
stmt = select(User).options(selectinload(User.posts)).where(User.id == user_id)
```
## Error Handling
- Use specific exception types, not bare `except:`
- FastAPI: raise `HTTPException` with appropriate status codes
- Service layer: raise domain-specific exceptions
- Never silently swallow exceptions
## Pydantic Models
```python
class UserResponse(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: str
name: str
email: str | None = None
created_at: datetime
```
## AI Gotchas
- **httpx vs requests**: Always use `httpx.AsyncClient` in async code
- **datetime**: Use `datetime.now(tz=UTC)` not `datetime.utcnow()` (deprecated)
- **Pydantic v2**: Use `model_config = ConfigDict(...)` not `class Config:`
- **SQLAlchemy 2.0**: Use `select()` not `session.query()`
Versions
The database has no other skills named trove-python.
Identical content appears in 3 other GitHub folders. We show one copy with the highest score.
Database snapshot: 13.11.2026 · package version 683eda3dbdfa (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100fastapi-pro
Production FastAPI patterns — async endpoints, SQLAlchemy 2.0 async, Pydantic V2, dependency injection, JWT auth, testing. Use for Python 3.11+ FastAPI backends. NOT for Django (→ `django-patterns`) or Node.js (→ `backend-patterns`). - 90python-fastapi
Build and review modern Python services with FastAPI, Pydantic v2, async SQLAlchemy, typing, uv/ruff/pytest. Use when writing Python APIs, workers or data-facing backends. - 100fastapi-pro
Build high-performance async APIs with FastAPI, SQLAlchemy 2.0, and Pydantic V2. Master microservices, WebSockets, and modern Python async patterns. Use for FastAPI development, async optimization, or API architecture. - 100fastapi-expert
Use when building high-performance async Python APIs with FastAPI and Pydantic V2. Invoke to create REST endpoints, define Pydantic models, implement authentication flows, set up async SQLAlchemy database operations, add JWT authentication, build WebSocket endpoints, or generate… - 100fastapi-expert
Use when building high-performance async Python APIs with FastAPI and Pydantic V2. Invoke to create REST endpoints, define Pydantic models, implement authentication flows, set up async SQLAlchemy database operations, add JWT authentication, build WebSocket endpoints, or generate… - 100fastapi-async-microservices
Design and develop production-grade asynchronous microservices using FastAPI, Python 3.12+, Pydantic v2 Settings and Schemas, SQLAlchemy 2.0 async sessions, dependency injection, lifespan state management, structured JSON logging, and connection pooling. Trigger when building…