Implementiert moderne Python Type Hints, strukturelles Typing mit Protocols und Type-Safety-Patterns für robusten Code.
- GitHub Stars
- 81
- Dateien
- 9
- Letzter Commit
- 7. Nov. 2026
- Lizenz
- MIT
- Erlaubte Tools
- 2
Was macht der python-typing-ops Skill?
python-typing-ops ist ein Agent Skill. Implementiert moderne Python Type Hints, strukturelles Typing mit Protocols und Type-Safety-Patterns für robusten Code.
Zusammenfassung erzeugt aus der SKILL.md des Skills.
Über den python-typing-ops skill
Dieses Skill ermöglicht es Entwicklern, moderne Python Type Hints und strukturelle Typing-Patterns zu implementieren, um sichere und dokumentierte Codebases aufzubauen. Es bietet einen umfassenden Satz an Tools für die Anwendung von Type Annotations, Generics und strukturellem Typing via Protocols, um die Code-Zuverlässigkeit zu gewährleisten. Wenn ein Agent dieses Skill lädt, kann er Code unter Verwendung fortgeschrittener Features wie TypeVar, TypedDict und Literal-Typen generieren oder refactoren.
Das Skill unterstützt die Syntax von Python 3.10+, einschließlich Union-Typen, sowie spezifische Patterns für Python 3.11+ wie Self und TypeVarTuple. Es hilft beim Konfigurieren und Ausführen von Type Checkern wie mypy und pyright, um die Code-Integrität zu validieren. Durch die Nutzung dieser Patterns können Entwickler über einfache Annotationen hinausgehen und komplexe Logik wie TypeGuards für Type Narrowing sowie strukturelles Typing für flexible Interface-Definitionen implementieren. Dies macht es zu einem essenziellen Tool für alle, die Laufzeitfehler durch statische Analyse reduzieren wollen.
Was ein agent damit machen kann
- 1Strukturelles Typing implementierenDefiniere ein Protocol, um zu ermöglichen, dass jedes Objekt mit einer spezifischen Methode an eine Funktion übergeben werden kann.
- 2Dictionaries mit festen Keys definierenErstelle ein TypedDict, um sicherzustellen, dass der Dictionary-Zugriff spezifische, typsichere Keys verwendet.
- 3Code mit Type Checkern validierenFühre mypy oder pyright Commands aus, um Type Errors in einem Source-Verzeichnis zu prüfen.
Geschrieben basierend auf dem SKILL.md des skills. Jeder use case wurde gegen ein zitat daraus geprüft.
So installierst du den python-typing-ops Skill
Jeder Befehl kopiert den Skill-Ordner in das Skills-Verzeichnis des Clients. Starte den Client neu oder beginne eine neue Session, um ihn zu laden.Den python-typing-ops Skill in Plugin installieren
/plugin marketplace add 0xDarkMatter/claude-mods /plugin install claude-mods@claude-mods
Den python-typing-ops Skill in Claude Code installieren
~/.claude/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.claude/skills/python-typing-opsDen python-typing-ops Skill in Claude Code (project) installieren
.claude/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops .claude/skills/python-typing-opsDen python-typing-ops Skill in Codex installieren
~/.agents/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.agents/skills/python-typing-opsDen python-typing-ops Skill in Gemini CLI installieren
~/.gemini/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.gemini/skills/python-typing-opsDen python-typing-ops Skill in Claude.ai installieren
npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops python-typing-ops && zip -r python-typing-ops.zip python-typing-ops # claude.ai → Customize → Skills → + → Create skill → Upload a skill → python-typing-ops.zip
Automatisierte Checks
Geluften am 14. Nov. 2026Vollständiger Bericht →Hat unsere automatischen Prüfungen bestanden. Das ist kein Sicherheitsaudit: Lesen Sie die Skripte, bevor ein Agent sie ausführt. Wie die Checks funktionieren
- Source Repository verknüpft und erreichbar0xdarkmatter/claude-mods/skills/python-typing-ops is public and reachablegithub.com/0xdarkmatter/claude-mods/tree/HEAD/skills/python- ↗Bestanden
- Open Source Lizenz (OSI)MITspdx.org/licenses/MIT.html ↗Bestanden
- Commit oder Release im letzten JahrLast commit 2026-11-07github.com/0xdarkmatter/claude-mods/commits ↗Bestanden
- Keine Download-und-Ausführen-Muster oder Zugangsdatendiebstahl in Skripten1 script read; no download-and-run, remote eval, base64 execution or credential uploadBestanden
- Keine versteckten Anweisungen in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗Bestanden
- Vorab erlaubte Tools sind eingeschränktPre-approved: Read, Writegithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗Bestanden
SKILL.md
Auf GitHub ansehenPython Typing Patterns
Modern type hints for safe, documented Python code.
Basic Annotations
# Variables
name: str = "Alice"
count: int = 42
items: list[str] = ["a", "b"]
mapping: dict[str, int] = {"key": 1}
# Function signatures
def greet(name: str, times: int = 1) -> str:
return f"Hello, {name}!" * times
# None handling
def find(id: int) -> str | None:
return db.get(id) # May return None
Collections
from collections.abc import Sequence, Mapping, Iterable
# Use collection ABCs for flexibility
def process(items: Sequence[str]) -> list[str]:
"""Accepts list, tuple, or any sequence."""
return [item.upper() for item in items]
def lookup(data: Mapping[str, int], key: str) -> int:
"""Accepts dict or any mapping."""
return data.get(key, 0)
# Nested types
Matrix = list[list[float]]
Config = dict[str, str | int | bool]
Optional and Union
# Modern syntax (3.10+)
def find(id: int) -> User | None:
pass
def parse(value: str | int | float) -> str:
pass
# With default None
def fetch(url: str, timeout: float | None = None) -> bytes:
pass
TypedDict
from typing import TypedDict, Required, NotRequired
class UserDict(TypedDict):
id: int
name: str
email: str | None
class ConfigDict(TypedDict, total=False): # All optional
debug: bool
log_level: str
class APIResponse(TypedDict):
data: Required[list[dict]]
error: NotRequired[str]
def process_user(user: UserDict) -> str:
return user["name"] # Type-safe key access
Callable
from collections.abc import Callable
# Function type
Handler = Callable[[str, int], bool]
def register(callback: Callable[[str], None]) -> None:
pass
# With keyword args (use Protocol instead)
from typing import Protocol
class Processor(Protocol):
def __call__(self, data: str, *, verbose: bool = False) -> int:
...
Generics
from typing import TypeVar
T = TypeVar("T")
def first(items: list[T]) -> T | None:
return items[0] if items else None
# Bounded TypeVar
from typing import SupportsFloat
N = TypeVar("N", bound=SupportsFloat)
def average(values: list[N]) -> float:
return sum(float(v) for v in values) / len(values)
Protocol (Structural Typing)
from typing import Protocol
class Readable(Protocol):
def read(self, n: int = -1) -> bytes:
...
def load(source: Readable) -> dict:
"""Accepts any object with read() method."""
data = source.read()
return json.loads(data)
# Works with file, BytesIO, custom classes
load(open("data.json", "rb"))
load(io.BytesIO(b"{}"))
Type Guards
from typing import TypeGuard
def is_string_list(val: list[object]) -> TypeGuard[list[str]]:
return all(isinstance(x, str) for x in val)
def process(items: list[object]) -> None:
if is_string_list(items):
# items is now list[str]
print(", ".join(items))
Literal and Final
from typing import Literal, Final
Mode = Literal["read", "write", "append"]
def open_file(path: str, mode: Mode) -> None:
pass
# Constants
MAX_SIZE: Final = 1024
API_VERSION: Final[str] = "v2"
Quick Reference
| Type | Use Case |
|---|---|
X | None |
Optional value |
list[T] |
Homogeneous list |
dict[K, V] |
Dictionary |
Callable[[Args], Ret] |
Function type |
TypeVar("T") |
Generic parameter |
Protocol |
Structural typing |
TypedDict |
Dict with fixed keys |
Literal["a", "b"] |
Specific values only |
Final |
Cannot be reassigned |
Type Checker Commands
# mypy (run inside the project env)
uv run mypy src/ --strict
# pyright
uv run pyright src/
# In pyproject.toml
[tool.mypy]
strict = true
python_version = "3.11"
Emerging: ty — Astral's Rust-based type checker (same toolchain as uv +
ruff), dramatically faster than mypy. Still in preview (pre-1.0), so mypy or
pyright remain the production default — but worth watching, and easy to try:
uvx ty check. Adopt for new projects once it stabilizes.
Additional Resources
./references/generics-advanced.md- TypeVar, ParamSpec, TypeVarTuple./references/protocols-patterns.md- Structural typing, runtime protocols./references/type-narrowing.md- Guards, isinstance, assert./references/mypy-config.md- mypy/pyright configuration./references/runtime-validation.md- Pydantic v2, typeguard, beartype./references/overloads.md- @overload decorator patterns
Scripts
./scripts/check-types.sh- Run type checkers with common options
Assets
./assets/pyproject-typing.toml- Recommended mypy/pyright config
See Also
This is a foundation skill with no prerequisites.
Related Skills:
python-pytest-ops- Type-safe fixtures and mocking
Build on this skill:
python-async-ops- Async type annotationspython-fastapi-ops- Pydantic models and validationpython-database-ops- SQLAlchemy type annotations
Dateien in diesem Skill
9python-typing-ops Skill-Fragen
Wie installiere ich den python-typing-ops Skill in Claude Code?
Führe npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.claude/skills/python-typing-ops aus. Claude Code lädt Skills aus ~/.claude/skills (alle Projekte) oder .claude/skills (ein Projekt) und nutzt einen Skill, wenn seine Beschreibung zur Aufgabe passt.
Welche Clients können den python-typing-ops Skill nutzen?
Jeder Client, der das Agent Skills-Format liest: Claude Code, Codex, Gemini CLI und claude.ai (als ZIP hochladen). Skripte im Skill laufen nur dort, wo der Client Codeausführung erlaubt.
Welche Python-Versionen werden für diese Patterns benötigt?
Die Patterns nutzen die Syntax von Python 3.10+ (wie die X | Y Union-Syntax), und einige spezifische Patterns wie Self oder TypeVarTuple erfordern Python 3.11+.
Wie kann ich Type Checker in meinem Projekt ausführen?
Du kannst mypy oder pyright via uv nutzen, zum Beispiel: 'uv run mypy src/ --strict' oder 'uv run pyright src/'.
Was ist der Unterschied zwischen Callable und Protocol für Funktionstypen?
Callable wird für einfache Funktionstypen verwendet, während Protocol genutzt wird, wenn du Keyword-Argumente spezifizieren musst.