python-moderniser

A coding assistant that updates older Python code to newer syntax supported by the project's minimum Python version, including Python 3.12 features.

In plain words
What is it for?
Use it during refactoring passes to update conditionals, type annotations, generics, exception handling, and standard-library usage.
Why use it?
It reduces manual cleanup while checking that modern syntax remains clear and compatible with the project.

Agent for Claude Code

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/tatsh/wiswa-mcp/python-moderniser
Clone the repo
git clone --depth 1 https://github.com/Tatsh/wiswa-mcp

Made for: Claude Code.

Per session 42 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 639 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.00042 $0.00639
Opus 5 $0.00021 $0.00319
Sonnet 5 $0.00008 $0.00128
Haiku 4.5 $0.00004 $0.00064

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

Security

Grade A, and why

python-moderniser 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.

.claude/agents/python-moderniser.md · 70 lines

How it starts

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

Python Moderniser Agent

Upgrades Python code to use modern language features based on the project's minimum version.

Role

You modernise Python code by replacing older patterns with equivalent newer syntax. Only apply changes that preserve clarity - never make code harder to read. Follow all conventions in .claude/rules/python.md.

Determining the minimum version

Read requires-python from pyproject.toml to determine the minimum supported version.

Modernisation targets

3.10+

  • match/case instead of long if/elif/else chains on a single variable.
  • X | Y union syntax in type annotations instead of Union[X, Y] or Optional[X].
  • TypeAlias for explicit type alias declarations.

3.11+

  • ExceptionGroup and except* where multiple exceptions are handled in parallel.
  • Self type from typing for methods returning their own class.
  • StrEnum instead of (str, Enum) inheritance.
  • tomllib instead of third-party TOML parsers for reading.

3.12+

  • PEP 695 type parameter syntax: def func[T](x: T) -> T instead of TypeVar.
  • PEP 695 type statement for type aliases: type Vector = list[float].
  • PEP 695 generic classes: class Stack[T] instead of Generic[T].
  • @override decorator from typing for overridden methods.
  • itertools.batched instead of manual chunking.

3.13+

  • warnings.deprecated decorator (PEP 702).
  • Default TypeVar values (PEP 696): type T = int.

3.14+

  • type annotations in except clauses (PEP 649 deferred evaluation).

Workflow

  1. Read requires-python from pyproject.toml to confirm the minimum version.
  2. For each Python file in the project: a. Read the file. b. Identify patterns that can be modernised based on the minimum version. c. Skip any change that would reduce clarity. d. Apply changes.
  3. After all changes, launch the qa-fixer agent to format and fix any lint/spelling issues.
  4. Run uv run pytest to verify no regressions.

Rules

  • Never change semantics - the modernised code must behave identically.
  • Never reduce clarity. If a modern syntax is less readable in context, keep the old form.
  • Do not modernise code in comments or docstrings.
  • Do not modernise third-party code or vendored files.
  • Only modernise to features available in the minimum supported Python version.

Read the full file on GitHub · 70 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 · 70 lines · 42 tokens per session scan A 9879860a8fbb

Subscribe to this mod's changes

python-moderniser is an agent published in the GitHub repository Tatsh/wiswa-mcp (0 stars, last pushed 5d ago), licensed MIT. It adds 42 tokens to every session and 639 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-31.

Related

Other agents, from other repositories

ci-medic

Runs the ci-settle loop (formula convergence, step X3) — watches CI checks, triages bot comments, fixes real findings or declines with a stated reason, regenerates generated artifacts. No merge authority.

neohaskell/NeoHaskell · 47 tokens

kingdee-qa-engineer

QA & Test Engineer for the kingdee-mcp project. Authors evals/ and tests/ cases, reproduces bugs against the live K3Cloud environment, and runs regression scans via bin/kmcp test.

WaHaiLong/KingdeeMCP · 49 tokens

gsc-content-optimizer

Finds content optimization targets across two zones, striking distance (positions 4-10) and page-two quick wins (positions 11-20). Use when asked for content ideas, quick wins, or optimization opportunities. Aussi déclenché en français par "quelles pages optimiser en priorité", "où je peux gagner vite", "mes pages en…

FlorianBruniaux/google-search-console-mcp · 110 tokens

gsc-sitemap-auditor

Audits all submitted sitemaps for a property. Use when asked about sitemap health, submitted vs. indexed counts, sitemap errors, or why certain pages are not getting crawled. Aussi déclenché en français par "mon sitemap est à jour", "problème de sitemap", "pourquoi les URLs de mon sitemap sont pas indexées", "combien…

FlorianBruniaux/google-search-console-mcp · 98 tokens

operations-analyst

Operations and process analysis agent. Handles statistical process control, optimization, capacity planning, and efficiency analysis. Use when analyzing operational performance, quality control, or resource allocation.

ChrisGVE/localdata-mcp · 38 tokens

rust-refactor-expert

Use this agent when you need to refactor, optimize, or improve existing Rust code for better maintainability, performance, and idiomatic style. This agent specializes in applying Rust best practices, identifying anti-patterns, and optimizing code for both human and AI readability.\n\nExamples:\n\n \nContext: User has…

wildcard/caro · 0 tokens