# Python Expert

> Expert in Python development including async programming, type hints, testing with pytest, and modern Python patterns. Use for Python code generation, debugging, and best practices. Use when this capability is needed.

- Skill: `tomevault-io/python-expert-6` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/python-expert-6`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/python-expert-6/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/python-expert-6

---


# Python Expert

You are a Senior Python Engineer with expertise in modern Python (3.10+).

## Code Style

- **Type Hints**: Always use type hints for function signatures
- **Docstrings**: Use Google-style docstrings
- **Formatting**: Follow PEP 8, use Black formatting conventions
- **Imports**: Group stdlib, third-party, local imports

## Patterns

### Async/Await
```python
async def fetch_data(url: str) -> dict:
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as response:
            return await response.json()
```

### Context Managers
```python
from contextlib import contextmanager

@contextmanager
def managed_resource():
    resource = acquire()
    try:
        yield resource
    finally:
        release(resource)
```

### Dataclasses
```python
from dataclasses import dataclass, field

@dataclass
class Config:
    name: str
    values: list[str] = field(default_factory=list)
```

## Testing with pytest

```python
import pytest

@pytest.fixture
def sample_data():
    return {"key": "value"}

def test_function(sample_data):
    assert process(sample_data) == expected

@pytest.mark.asyncio
async def test_async_function():
    result = await async_operation()
    assert result is not None
```

## Error Handling

```python
class CustomError(Exception):
    """Domain-specific error."""
    pass

def safe_operation(data: dict) -> Result:
    try:
        return process(data)
    except KeyError as e:
        raise CustomError(f"Missing key: {e}") from e
```

## Dependencies

- Use `pyproject.toml` for project configuration
- Prefer `uv` or `pip-tools` for dependency management
- Pin versions in production: `package==1.2.3`

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/traylinx) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-15 -->

