python-modern-python

Solid

Modern Python language features and typing patterns. Use when writing type hints, using generics, implementing pattern matching, working with async/await, or leveraging Python 3.10+ features.

AI & Automation 38 stars 3 forks Updated today MIT

Install

View on GitHub

Quality Score: 87/100

Stars 20%
53
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Modern Python Features Modern Python 3.10+ language features, type hints, and patterns. ## Type Hints ### Basic Types ```python def greet(name: str) -> str: return f"Hello {name}" age: int = 25 prices: list[float] = [9.99, 19.99] mapping: dict[str, int] = {"a": 1} ``` ### Union Types (Python 3.10+) ```python # Modern syntax def process(value: int | str) -> bool: ... # Optional def get_user(id: int) -> User | None: ... # Multiple types Result = int | str | bool ``` ### Generic Types ```python from typing import TypeVar, Generic T = TypeVar("T") class Repository(Generic[T]): def get(self, id: int) -> T | None: ... def save(self, entity: T) -> T: ... user_repo = Repository[User]() ``` ### Protocol (Structural Typing) ```python from typing import Protocol class Drawable(Protocol): """Structural type - any class with draw()""" def draw(self) -> None: ... def render(obj: Drawable) -> None: """Works with any object that has draw()""" obj.draw() ``` ## Pattern Matching (Python 3.10+) ### Basic Matching ```python def handle_command(command: str): match command: case "start": start_process() case "stop": stop_process() case "status": return get_status() case _: raise ValueError("Unknown command") ``` ### Matching with Values ```python def handle_http_status(status: int): match status: case 200: ...

Details

Author
martinffx
Repository
martinffx/atelier
Created
6 months ago
Last Updated
today
Language
TypeScript
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category