python-type-safety
Python type safety with type hints, generics, protocols, and strict type checking. Use when adding type annotations, implementing generic classes, defining structural interfaces, or configuring mypy/pyright.
Installation
Pick a client and clone the repository into its skills directory.
Installation
About this skill
Python type safety with type hints, generics, protocols, and strict type checking. Use when adding type annotations, implementing generic classes, defining structural interfaces, or configuring mypy/pyright.
How to use
Zainstaluj skill python-type-safety w swoim środowisku agenta — dodaj go do konfiguracji pluginów python-development.
Zaznacz wszystkie publiczne sygnatury funkcji i metod adnotacjami typów. Dla każdej funkcji określ typy parametrów i wartości zwracanej, np.
def get_user(user_id: str) -> User | None:.Gdy pracujesz z kodem, który może zwrócić None lub wiele typów, użyj type narrowing — dodaj warunkowe sprawdzenia (if user is None), aby zawęzić typ w danym bloku kodu.
Dla kodu wielokrotnego użytku zastosuj generyki — napisz klasy i funkcje, które zachowują informacje o typach dla różnych danych, np.
BatchResult[ProcessedItem].Definiuj interfejsy strukturalne za pomocą protokołów zamiast dziedziczenia — pozwala to na duck typing z bezpieczeństwem typów.
Skonfiguruj mypy lub pyright w swoim projekcie i uruchom je regularnie — narzędzia te automatycznie walidują adnotacje i wyłapują niezgodności typów przed testowaniem.