annotate, run mypy, fixstatic — it never runs your code
X | None is the winmypy forces you to handle None before use
built-in genericslist[int], dict[str, float] — no typing.List anymore
Protocol = duck typing, typedstructural match, no inheritance needed
[T] inline generics (3.12+)def first[T](xs: list[T]) -> T
strict = truethe target for new code; adopt flags gradually on legacy
narrowing refines unionsisinstance / is None / assert
type: ignore[code], never bareand turn on warn_unused_ignores
annotate empty containersx: list[int] = [] or you get list[Any]
Any silences checkinguse object when you mean "anything but still checked"