python-best-practices
Pythonic code with modern type hints, dataclasses, async patterns, packaging, and testing
npx skills add rohitg00/awesome-claude-code-toolkit --skill python-best-practices --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Python Best Practices ## Type Hints (3.12+ Syntax) ```python # Use built-in generics (3.9+), no need for typing.List, typing.Dict def process_items(items: list[str]) -> dict[str, int]: return {item: len(item) for item in items} # Union with | syntax (3.10+) def find_user(user_id: int) -> User | None: ... # Type parameter syntax (3.12+) type Vector[T] = list[T] type Matrix[T] = list[Vector[T]] def first[T](items: list[T]) -> T: return items[0] # TypedDict for structured dicts from typing import TypedDict class UserResponse(TypedDict): id: int name: str email: str active: bool ``` Always type function signatures. Use `mypy --strict` or `pyright` in CI. Use `type: ignore` comments sparingly with justification. ## Dataclasses vs Pydantic ### Dataclasses (internal data, no validation needed) ```python from dataclasses import dataclass, field @dataclass(frozen=True, slots=True) class Point: x: float y: float def distance_to(self, other: "Point") -> float: return ((self.x - other.x) ** 2 + (self.y - other.y) ** 2) ** 0.5 @dataclass class Config: host: str = "localhost" port: int = 8080 tags: list[str] = field(default_factory=list) ``` Use `frozen=True` for immutable value objects. Use `
- Type Hints (3.12+ Syntax)
- Dataclasses vs Pydantic
- Dataclasses (internal data, no validation needed)
- Pydantic (external input, validation required)
- Async Patterns
- Project Structure
- pyproject.toml
- Virtual Environments
- Testing with pytest
- Pythonic Idioms
- Error Handling
Use uv for fast dependency management uv venv uv pip install -e ".[dev]" Or standard venv python -m venv .venv source .venv/bin/activate pip install -e ".[dev]"
What does the python-best-practices skill do?
Pythonic code with modern type hints, dataclasses, async patterns, packaging, and testing
How do I install it?
Run `npx skills add rohitg00/awesome-claude-code-toolkit --skill python-best-practices --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From rohitg00/awesome-claude-code-toolkit, a repository with 2,438 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.