- Home
- Skills
- Code Quality & Review
- Python Modernizer
Works with the AI Agents you already use
Python Modernizer
Automated Python code modernization for f-strings, type hints, and legacy syntax patterns.
$1
Python Modernizer
Example session with this skill installed
Modernize the typing and string formatting in app/services/auth.py for Python 3.10. I want to see the diff first.
- Read your context and instructions
- Compiled the python modernizer
I have analyzed app/services/auth.py for Python 3.10 compatibility. Below is the diff report for f-strings and modern type union syntax.
Modernization Diff (app/services/auth.py)
--- app/services/auth.py
+++ app/services/auth.py
@@ -1,15 +1,14 @@
-from typing import List, Optional, Union
+from typing import List
class AuthProvider:
- def __init__(self, provider_name: str):
- self.message = "Initializing %s provider" % provider_name
+ def __init__(self, provider_name: str) -> None:
+ self.message = f"Initializing {provider_name} provider"
- def get_users(self, role: Optional[str] = None) -> Union[List[str], None]:
+ def get_users(self, role: str | None = None) -> list[str] | None:
"""Fetch users by role."""
if role is None:
return []
- print("Fetching for: {}".format(role))
+ print(f"Fetching for: {role}")
return ["admin", "editor"]
- def log_error(self, code: int, msg: str):
- return "Error %d: %s" % (code, msg)
+ def log_error(self, code: int, msg: str) -> str:
+ return f"Error {code}: {msg}"
Advisory Notes
- Found
type(role) == stron line 22. Consider replacing withisinstance(role, str). - Redundant
open(file, 'r')detected on line 45; the'r'mode is default in Python 3.
Next steps
- Run with
--writeto apply these 6 changes to the file. - Execute your test suite to verify the
f-stringinterpolation logic. - Review the
isinstanceadvisory to ensure type checking remains strict.
Connects securely to your tools. The creator never sees your data.
About this skill
Legacy Python code slows down development and introduces technical debt that modern linters flag. This skill automates the transition to modern idioms, moving your codebase from outdated patterns to clean, efficient syntax compatible with Python 3.9 through 3.11+.
What it does
- Syntax Upgrades converts legacy
%and.format()strings to modern f-strings. - Type Hinting Modernization migrates
typing.ListorUnionto built-in generics and pipe syntax. - Boilerplate Removal strips redundant
objectinheritance,super()arguments, anduprefixes. - Resource Cleanup optimizes
open()calls and literal constructors likedict()orlist(). - Advisory Reporting flags complex patterns like
pathlibmigrations ordataclassopportunities without risky auto-changes.
How it works
- Analyze Provide a file or directory to scan for legacy patterns against a target Python version.
- Preview Review the diff report to see proposed changes without modifying the source.
- Select Use specific flags to isolate certain modernizations like f-strings or typing only.
- Apply Execute the write command to update files with verified, parsed code changes.
Frameworks & tools
This skill operates on standard Python source code and targets syntax features introduced in Python 3.9, 3.10, and 3.11.
Why this beats prompting it yourself
Generic prompts often hallucinate syntax or break complex logic during string formatting. This skill uses a logic-heavy approach that validates every rewrite against a parser to ensure code remains valid while strictly following version-specific PEP standards.
Use cases
- Version Upgrades when migrating a service from Python 3.7 to 3.10+.
- Technical Debt Reduction before a major refactor or library migration.
- Codebase Standardization to enforce consistent modern idioms across a team.
Known limitations
Does not auto-rewrite == None or pathlib transitions as these can impact library behavior. String conversions are restricted to simple cases to prevent breakage.
Manual testing is required after writing changes. Complex string formatting and behavioral changes like pathlib or dataclasses are reported but not auto-modified.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 1 month ago