en un clic
python
Write Python code following best practices. Use when developing Python applications. Covers type hints, async, and modern tooling.
Menu
Write Python code following best practices. Use when developing Python applications. Covers type hints, async, and modern tooling.
Basé sur la classification professionnelle SOC
Biome 2.x linting and formatting patterns. Use when configuring code quality tools, setting up linting rules, formatting code, or integrating with CI/CD. Covers migration from ESLint/Prettier.
Hono 4.x web framework patterns. Use when building APIs, middleware, routing, or server-side applications. Covers multi-runtime support (Node, Bun, Cloudflare Workers), validation, CORS, and error handling.
Radix UI primitive patterns. Use when building accessible, unstyled UI components like dialogs, dropdowns, tooltips, tabs, and selects. Covers Tailwind styling, keyboard navigation, animations, and portal management.
React development patterns. Use when building React components, managing state, creating custom hooks, or optimizing React applications. Covers React 19 features, TypeScript integration, and composition patterns.
Tailwind CSS 4.x utility-first styling patterns. Use when building UI components, creating responsive layouts, implementing design systems, or customizing themes. Covers CSS-first configuration, @theme directive, and component patterns.
Vite 7.x build tool patterns. Use when configuring build setup, development server, environment variables, asset handling, or optimizing production builds for React applications.
| name | python |
| description | Write Python code following best practices. Use when developing Python applications. Covers type hints, async, and modern tooling. |
# Create project with uv
uv init my-project
cd my-project
# Add dependencies
uv add litestar
uv add --dev pytest ruff mypy
[project]
name = "my-project"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = ["litestar>=2.0"]
[tool.ruff]
line-length = 88
target-version = "py313"
[tool.mypy]
strict = true
python_version = "3.13"
from typing import TypeVar, Generic
from collections.abc import Sequence
T = TypeVar('T')
class Repository(Generic[T]):
async def find_by_id(self, id: str) -> T | None:
...
async def save(self, entity: T) -> T:
...
def process_items(items: Sequence[str]) -> list[str]:
return [item.upper() for item in items]
import asyncio
from collections.abc import AsyncIterator
async def fetch_all(urls: list[str]) -> list[Response]:
async with aiohttp.ClientSession() as session:
tasks = [fetch_one(session, url) for url in urls]
return await asyncio.gather(*tasks)
async def stream_data() -> AsyncIterator[bytes]:
async with aiofiles.open('large.csv', 'rb') as f:
async for chunk in f:
yield chunk
from dataclasses import dataclass
from typing import TypeVar, Generic
T = TypeVar('T')
E = TypeVar('E')
@dataclass
class Ok(Generic[T]):
value: T
@dataclass
class Err(Generic[E]):
error: E
Result = Ok[T] | Err[E]
def divide(a: int, b: int) -> Result[float, str]:
if b == 0:
return Err("Division by zero")
return Ok(a / b)
import pytest
from unittest.mock import AsyncMock
@pytest.mark.asyncio
async def test_create_user():
repo = AsyncMock()
service = UserService(repo)
user = await service.create("test@example.com")
assert user.email == "test@example.com"
repo.save.assert_called_once()
@pytest.fixture
def mock_database():
with patch('app.database') as mock:
yield mock
# Ruff (linting + formatting)
ruff check --fix .
ruff format .
# MyPy (type checking)
mypy --strict .
# pytest
pytest -v --cov=src