- Home
- Skills
- Code Quality & Review
- Python Modernizer
Works with the AI tools you already use
Python Modernizer
Automated Python code modernization for f-strings, type hints, and legacy syntax patterns.
$9.99
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.
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean today
- Passed all security checks, Safe to install