Interview frequency: …
Short answer
No; annotations are metadata read by static analysis tools such as mypy and Pyright, and they do not stop Python from passing a value of a different type at runtime.
Explanation
Annotations are stored in __annotations__ and can be read programmatically, which is why libraries such as Pydantic and FastAPI use them for runtime validation, but that is library behavior, not the language. Run a type checker in CI alongside the tests, and validate explicitly at system boundaries (HTTP requests, user files, environment variables). Since Python 3.14 annotations are evaluated lazily (PEP 649), so you usually no longer need from __future__ import annotations.
Code example
def total(prices: list[float]) -> float:
return sum(prices)
total(["1", "2"]) # No error from Python itself
# TypeError Only when using sum; mypy catches it before execution:
# error: List item 0 has incompatible type "str"Common mistakes
- Relying on type hints as a substitute for validating user input.
- Adding annotations without running a type checker in CI, so they rot unnoticed.