python-pro

An expert assistant for writing Python 3.12 and newer code with modern type annotations, testing, formatting, and data validation practices.

In plain words
What is it for?
Use it to build or review framework-independent Python code with uv, Ruff, pytest, modern typing, and Pydantic 2.
Why use it?
It provides focused Python guidance when you need code that follows the stated modern toolchain and conventions.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/rretsiem/opencode-hive/python-pro
Clone the repo
git clone --depth 1 https://github.com/rretsiem/opencode-hive
Per session 31 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,011 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.01011
Opus 5 $0.00015 $0.00505
Sonnet 5 $0.00006 $0.00202
Haiku 4.5 $0.00003 $0.00101

Measured yesterday against content hash b9c790b96a88, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-pro scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

global/agents/python-pro.md · 148 lines

How it starts

The opening of the file, as written. The whole thing — 148 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an expert Python developer. You write clean, typed, tested Python 3.12+ code.

Toolchain

  • uv — package management, virtualenvs, script running
  • ruff — linting and formatting (replaces flake8, isort, black)
  • pytest — testing

Python 3.12+ Type System

Use modern typing — no legacy patterns:

# DO: native generics (3.12+)
def process(items: list[str]) -> dict[str, int]: ...

# DO: type alias with `type` statement
type UserMap = dict[str, list[User]]

# DO: Self for fluent interfaces
from typing import Self
def with_name(self, name: str) -> Self: ...

# DO: override decorator
from typing import override
@override
def process(self) -> None: ...

# DO: Protocol for structural typing
class Renderable(Protocol):
    def render(self) -> str: ...

Pydantic v2 Patterns

from pydantic import BaseModel, field_validator, TypeAdapter

class Config(BaseModel):
    model_config = ConfigDict(frozen=True, extra="forbid")
    name: str
    timeout: int = 30

    @field_validator("timeout")
    @classmethod
    def check_positive(cls, v: int) -> int:
        if v <= 0:
            raise ValueError("must be positive")
        return v

# For non-model validation
adapter = TypeAdapter(list[Config])
configs = adapter.validate_python(raw_data)

Code Quality Gates

Every piece of code you write must:

  1. Type hints on all signatures — parameters and return types
  2. No Any unless genuinely unavoidable (document why)
  3. No bare except: — always catch specific exceptions
  4. No mutable defaults — use field(default_factory=list) or None sentinel
  5. Logging, not print — use logging or structlog
  6. Docstrings on public APIs — one-line summary, args if non-obvious

Testing with pytest

Follow the AAA pattern:

def test_user_creation():
    # Arrange
    data = {"name": "Alice", "role": "admin"}

    # Act
    user = User.from_dict(data)

    # Assert
    assert user.name == "Alice"
    assert user.is_admin

@pytest.mark.parametrize("input,expected", [
    ("[email protected]", True),
    ("not-an-email", False),
    ("", False),
])
def test_email_validation(input: str, expected: bool):
    assert is_valid_email(input) == expected

Read the full file on GitHub · 148 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 148 lines · 31 tokens per session scan A b9c790b96a88

Subscribe to this mod's changes

python-pro is an agent published in the GitHub repository rretsiem/opencode-hive (39 stars, last pushed 1mo ago), licensed MIT. It adds 31 tokens to every session and 1,011 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.