Reliable Typed Python Applications

Build typed Python modules with bounded async work, explicit error handling, strict mypy checks, and focused pytest coverage.

Development / Languagespythontype-safety
by AgentVoltv1.0.0
Free to sign up · every skill included with AgentVolt Pro

Before & after

Same prompt, same agent — the only difference is the skill.

Prompt“Write production-grade Python code with strict type checking”
Beforegeneric AI agent
I can write Python code for you. I'll make sure it works correctly and is reasonably well-structured. For type hints, I can add basic type annotations to function arguments and return values. For testing, I'll write some test cases to make sure the code works. If you have specific requirements like async support or error handling patterns, I can include those too. Just let me know what you're building and I'll write the code with best practices in mind.
Afterwith Reliable Typed Python Applications
PYTHON PRO: PRODUCTION CHECKLIST

CODE STYLE
✓ Type hints: strict mode enabled (mypy --strict on all files)
✓ All functions annotated: params + return types
✓ Dataclasses used for models (frozen=True for immutable)
✓ Black formatting applied (line length 88)
✓ Ruff checks pass (all categories)

ASYNC PATTERNS
✓ Async functions: use async/await, no blocking calls in event loop
✓ Dependency injection: accept clients as params, never global singletons
✓ Error handling: custom exceptions (inherit from base exception class)
✓ Logging: structured JSON logs (include context, trace_id)

TEST SUITE
✓ Pytest fixtures: isolated test database, mock clients
✓ Mocking: external APIs mocked (requests-mock), no live calls
✓ Coverage: 85% minimum, gaps flagged in CI
✓ Parametrized tests: test multiple inputs in 1 test function
✓ Slow tests: marked with @pytest.mark.slow, skipped in fast mode

SCRIPT EXAMPLE OUTPUT
# models.py
@dataclass(frozen=True)
class User:
    id: int
    name: str
    email: str

async def fetch_user(user_id: int, db: Database) -> User:
    """Fetch user from database. Raises UserNotFoundError if missing."""
    result = await db.query("SELECT * FROM users WHERE id = ?", user_id)
    if not result:
        raise UserNotFoundError(f"User {user_id} not found")
    return User(**result)

# tests/test_models.py
@pytest.mark.asyncio
async def test_fetch_user_success(mock_db):
    mock_db.query.return_value = {"id": 1, "name": "Alice", "email": "alice@x.com"}
    user = await fetch_user(1, mock_db)
    assert user.id == 1

About this skill

“My async code keeps hanging” and “mypy only passes because everything is Any” point to problems that annotations alone cannot fix. This skill builds and reviews Python code around validated boundaries, explicit failure behavior, bounded concurrency, and tests that expose those failures.

What it does

  • Replaces leaking Any types with validated inputs, narrow domain models, and small typed interfaces.
  • Finds blocking calls, swallowed cancellation, unbounded task creation, and resources that outlive their owners.
  • Separates invalid input, transport failures, deadlines, and programming errors without flattening them into one exception.
  • Adds strict mypy checking and linting that fit the project's existing configuration.
  • Writes pytest cases for observable failure behavior, cleanup, and concurrency rather than implementation details.
  • Delivers scoped patches or complete modules with exact verification commands and honest execution status.

What you get

Usable Python code or an evidence-based review, plus focused tests and any necessary configuration changes. Async implementations explain who owns resources, what the deadline covers, and how failures and cancellation propagate.

Best for

Developers maintaining Python 3.11+ applications, libraries, background workers, and async integrations who need stronger guarantees without turning a small fix into a framework migration.

SKILL.md preview

SKILL.md
---
name: reliable-typed-python-applications
description: Builds and reviews Python 3.11+ code using validated type boundaries, strict mypy checking, cancellation-safe async patterns, explicit exceptions, and focused pytest tests. Use when the user says "make this Python production-ready", "my async code keeps hanging", "fix these mypy errors", "add type hints without Any", "review this Python module", "write pytest failure-path tests", or "stop blocking the event loop".
---

# Reliable Typed Python Applications

… (sign up to view the full skill)
Sign up to view, copy, and install the full skill

More development skills

View all Development skills →