- Home
- Skills
- Martinffx
- Claude Code Atelier
- Atelier Python Modern Python
atelier-python-modern-python_skill
- JavaScript
4
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill martinffx/claude-code-atelier --skill atelier-python-modern-python- SKILL.md3.8 KB
Overview
This skill teaches and applies Modern Python 3.10+ language features, type hints, and idiomatic patterns. It helps you write clearer type annotations, use structural typing and generics, adopt pattern matching, and implement async/await correctly. The goal is safer, more maintainable Python code using current best practices.
How this skill works
I inspect code for opportunities to modernize types (PEP 604 unions, bracketed generics), suggest Protocol-based interfaces, and recommend dataclass/attrs designs for immutable models. I identify where structural pattern matching simplifies conditionals, convert sync flows to async/await and asyncio.gather where concurrency is appropriate, and suggest idiomatic uses of the walrus operator and f-strings. I provide refactor examples and concise code snippets you can drop into your codebase.
When to use it
- Adding or improving type hints across modules, including unions and generics.
- Designing lightweight interfaces using Protocols instead of abstract base classes.
- Replacing complex if/elif chains with structural pattern matching.
- Converting blocking I/O to async/await and orchestrating concurrent tasks.
- Creating immutable data models with dataclasses or attrs.
- Cleaning up formatting with f-strings and using the walrus operator for concise expressions.
Best practices
- Prefer PEP 604 union syntax (A | B) and bracketed built-ins (list[int]) for readability.
- Use TypeVar and Generic for reusable container or repository types, and lean on Protocol for duck-typed interfaces.
- Apply pattern matching to clearly express branching logic for structured data; keep cases small and focused.
- Keep async entry points isolated; avoid mixing blocking calls inside async functions—use thread pools if necessary.
- Make dataclasses frozen when instances should be immutable and implement simple methods on them for clarity.
- Use the walrus operator sparingly where it reduces repetition without harming readability.
Example use cases
- Refactoring a service layer to return typed Repository[T] instances and removing runtime type checks.
- Replacing a large switch/if tree for command handling with match/case structural patterns.
- Converting parallel HTTP fetches to asyncio.gather with proper error handling and timeouts.
- Defining lightweight UI or drawing interfaces with Protocol to reduce coupling between components.
- Modeling domain objects as frozen dataclasses and adding computed methods for derived values.
FAQ
No. Protocols are used for static type checking and structural typing; they do not change runtime class hierarchies.
When should I prefer dataclass over attrs?
Use dataclass for standard use cases included in the stdlib; use attrs when you need advanced validators or more customization.