Loading...
Loading...
Modern Python development with uv, ruff, mypy, and pytest. Use when: - Writing or reviewing Python code - Setting up Python projects or pyproject.toml - Choosing dependency management (uv, poetry, pip) - Configuring linting, formatting, or type checking - Organizing Python packages Keywords: Python, pyproject.toml, uv, ruff, mypy, pytest, type hints, virtual environment, lockfile, package structure
npx skill4agent add phrazzld/claude-config python-standards| Tool | Purpose |
|---|---|
| uv | Dependencies + virtual envs (lockfile: |
| ruff | Linting + formatting (replaces black, isort, flake8) |
| mypy | Type checking (strict mode) |
| pytest | Testing + coverage |
# Setup
uv init && uv add <deps> && uv sync
# Daily workflow
uv run ruff check . --fix && uv run ruff format .
uv run mypy . && uv run pytestdef fetch_user(user_id: str) -> User | None:
"""Fetch user by ID."""
...
def process_items(items: list[Item]) -> dict[str, int]:
...[tool.mypy]
strict = true
disallow_untyped_defs = true
disallow_any_generics = truesrc/myproject/
users/ # Domain
__init__.py # Public API: __all__ = ['User', 'UserService']
models.py
services.py
orders/ # Another domain
shared/ # Cross-cutting concernstry:
result = parse_config(path)
except FileNotFoundError:
logger.warning(f"Config not found: {path}")
return defaults
except json.JSONDecodeError as e:
raise ConfigError(f"Invalid JSON in {path}") from eexcept:except Exception[project]
name = "myproject"
version = "1.0.0"
requires-python = ">=3.11"
dependencies = ["httpx", "pydantic"]
[project.optional-dependencies]
dev = ["pytest", "mypy", "ruff"]
[tool.ruff]
select = ["E", "W", "F", "I", "B", "UP", "SIM", "S", "ANN"]
line-length = 88
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = ["--cov=src", "--cov-fail-under=85"]Any/controllers/models/viewsnoqa