name: python-expert-tests
skill: python-expert
version: 1.0.0
cases:
  - id: type-hints-required
    description: Should insist on type hints and reject untyped signatures
    prompt: Write a Python function that takes a list of users and returns those who are active. Keep it simple, no type hints needed.
    expected:
      contains_any:
        - "list["
        - "-> list"
        - "List["
        - ": list"
      not_contains:
        - no type hints needed
        - type hints are optional
      min_length: 50
    tags: [core, types]

  - id: rejects-bare-except
    description: Should flag bare except as a bug and suggest proper exception handling
    prompt: Is it okay to use bare except in Python? My code sometimes crashes and I want to catch everything.
    expected:
      contains_any:
        - bare except
        - "except:"
        - specific exception
        - re-raise
      not_contains:
        - "yes, it's fine"
        - perfectly acceptable
      min_length: 80
    tags: [core, error-handling]

  - id: dataclass-over-dict
    description: Should recommend dataclasses or Pydantic over raw dicts for structured data
    prompt: I'm passing user data around my app as dicts with keys like name, email, role. Is there a better way?
    expected:
      contains_any:
        - dataclass
        - Pydantic
        - TypedDict
        - frozen
      min_length: 80
    tags: [core, patterns]

  - id: async-no-blocking
    description: Should catch blocking calls inside async functions
    prompt: I have an async FastAPI endpoint that calls requests.get() to fetch data. It works but sometimes feels slow.
    expected:
      contains_any:
        - blocking
        - httpx
        - aiohttp
        - event loop
        - async client
      min_length: 80
    tags: [core, async]

  - id: di-over-patch
    description: Should recommend dependency injection over monkeypatching in tests
    prompt: How should I test a function that sends emails? Should I use unittest.mock.patch?
    expected:
      contains_any:
        - dependency injection
        - inject
        - interface
        - Protocol
        - "Mock(spec="
      min_length: 80
    tags: [core, testing]

  - id: coding-easy-retry-decorator
    description: "Coding challenge (easy): Write a retry decorator with configurable attempts"
    prompt: "Write a Python decorator called retry that takes max_attempts and delay_seconds parameters. It should retry the decorated function on any exception up to max_attempts times, waiting delay_seconds between attempts. Include proper type hints."
    expected:
      contains_any:
        - def retry
        - wrapper
        - attempts
        - except
        - sleep
      contains:
        - def
      not_contains:
        - "I can't write"
      min_length: 100
    tags:
      - coding-easy

  - id: coding-medium-lru-cache
    description: "Coding challenge (medium): Implement an LRU cache from scratch"
    prompt: "Write a Python LRU cache class with a configurable max size. It should support get and put operations in O(1) time using a combination of a dictionary and doubly-linked list. Include type hints and handle edge cases like updating existing keys."
    expected:
      contains_any:
        - class
        - dict
        - node
        - capacity
        - evict
      contains:
        - def get
        - def put
      min_length: 200
    tags:
      - coding-medium

  - id: coding-hard-async-pipeline
    description: "Coding challenge (hard): Build an async data processing pipeline with backpressure"
    prompt: "Write a Python async pipeline framework where you chain processing stages. Each stage is an async callable that transforms items. The pipeline should support: configurable buffer size between stages (backpressure), error handling per-item without stopping the pipeline, graceful shutdown via cancellation, and collecting results or streaming them via an async iterator."
    expected:
      contains_any:
        - async def
        - asyncio
        - Queue
        - await
        - yield
        - buffer
      contains:
        - class
      min_length: 300
    tags:
      - coding-hard
