Advanced Python development with architecture expertise and automated code quality enforcement.
Expert-level Python development skill with senior architect capabilities, automated code quality tools, and comprehensive best practices.
Use bundled scripts to enforce code quality:
Run all quality checks:
uv run python scripts/check_quality.py [target_directory]
This runs:
Auto-fix common issues:
uv run python scripts/autofix.py [target_directory]
Auto-fixes:
Create new Python projects with best practices:
uv run python scripts/init_project.py <project-name> [path]
Creates:
src/ layout)pyproject.toml with Ruff, MyPy, PytestSee code_quality.md for detailed standards on:
See architecture_patterns.md for:
def process_data(
items: Sequence[dict[str, Any]],
max_count: int = 100,
) -> list[ProcessedItem]:
...
# Use match statements (3.10+)
match status:
case 200:
return response.json()
case 404:
raise NotFoundError()
case _:
raise APIError(status)
def calculate_metrics(data: pd.DataFrame) -> dict[str, float]:
"""Calculate statistical metrics from data.
Args:
data: Input DataFrame with numeric columns
Returns:
Dictionary mapping metric names to values
Raises:
ValueError: If data is empty
"""
uv run python scripts/autofix.pyuv run python scripts/check_quality.pyAll tools are configured via pyproject.toml:
Ruff: Line length 100, Python 3.12+, comprehensive rule set MyPy: Strict mode with no untyped definitions Pytest: Coverage reporting with missing lines Coverage: Excludes test files and common patterns
from typing import Protocol
class Repository(Protocol):
def save(self, item: Item) -> None: ...
class Service:
def __init__(self, repo: Repository) -> None:
self.repo = repo
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
database_url: str
api_key: str
model_config = {"env_file": ".env"}
class DomainError(Exception):
"""Base for all domain errors."""
pass
class ValidationError(DomainError):
"""Invalid input data."""
pass
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)
Install dev dependencies:
uv add --dev ruff mypy pytest pytest-cov bandit
Run single tool:
uv run ruff check .
uv run mypy .
uv run pytest
uv run bandit -r .
Format code:
uv run ruff format .
Type check:
uv run mypy --strict .