python-type-hints
Installation
SKILL.md
Quick Reference
| Type | Syntax (3.9+) | Example |
|---|---|---|
| List | list[str] |
names: list[str] = [] |
| Dict | dict[str, int] |
ages: dict[str, int] = {} |
| Optional | str | None |
name: str | None = None |
| Union | int | str |
value: int | str |
| Callable | Callable[[int], str] |
func: Callable[[int], str] |
| Feature | Version | Syntax |
|---|---|---|
| Type params | 3.12+ | def first[T](items: list[T]) -> T: |
| type alias | 3.12+ | type Point = tuple[float, float] |
| Self | 3.11+ | def copy(self) -> Self: |
| TypeIs | 3.13+ | def is_str(x) -> TypeIs[str]: |