trove-python
/trove-python
Podaje konwencje kodowania w Pythonie i FastAPI: asynchroniczność, podpowiedzi typów, SQLAlchemy, Pydantic i obsługę błędów.
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 2
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 08.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
- SKILL.md zawiera komentarze HTML (2). Nie widać ich w podglądzie Markdown, a model je czyta.
Co robi i kiedy
Podaje konwencje kodowania w Pythonie i FastAPI: asynchroniczność, podpowiedzi typów, SQLAlchemy, Pydantic i obsługę błędów.
Oryginalny opis (EN)
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.
Jak działa
- Session Init
- Imports
- Type Hints
- Async Patterns (CRITICAL)
- Logging
- SQLAlchemy Async
- Error Handling
- Pydantic Models
- AI Gotchas
Podgląd SKILL.md
---
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()`
Wersje
W bazie nie ma innych skilli o nazwie trove-python.
Identyczna treść występuje jeszcze w 3 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.
Migawka bazy z 13.11.2026 · wersja paczki 683eda3dbdfa (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100fastapi-pro
Podaje produkcyjne wzorce FastAPI dla Pythona 3.11+: endpointy async, SQLAlchemy 2.0 async, Pydantic V2, wstrzykiwanie zależności, JWT i testy. - 90python-fastapi
Buduje i przegląda usługi w Pythonie na FastAPI, Pydantic v2 i asynchronicznym SQLAlchemy, z typowaniem, uv, ruff i pytest. - 100fastapi-pro
Buduje szybkie asynchroniczne API w FastAPI, SQLAlchemy 2.0 i Pydantic V2, także mikrousługi i WebSockety. - 100fastapi-expert
Buduje asynchroniczne API w Pythonie z FastAPI i Pydantic V2: endpointy REST, modele, JWT, SQLAlchemy async, WebSocket i OpenAPI. - 100fastapi-expert
Buduje asynchroniczne API w FastAPI i Pydantic V2: endpointy REST, modele, uwierzytelnianie JWT, async SQLAlchemy, WebSockets i dokumentacja OpenAPI. - 100fastapi-async-microservices
Projektuje produkcyjne asynchroniczne mikrousługi w FastAPI i Pythonie 3.12+: Pydantic v2, SQLAlchemy 2.0 async, stan lifespan, logi JSON i pule połączeń.