What do Python type hints do at runtime by default?
Type hints: annotations like def f(x: int) -> str are not enforced at runtime; Python ignores them during execution. Static checkers like mypy and IDEs use them to catch bugs before running.
2 / 5
What does Optional[str] mean?
Optional:Optional[str] is shorthand for Union[str, None], declaring the value may be a string or None. It documents nullable parameters and lets checkers warn about missing None handling.
3 / 5
What is a generic type such as list[int]?
Generics:list[int] states the list holds integers. Generics let you express container element types so tools verify you do not, say, append a string to a list of ints.
4 / 5
What is the purpose of a static type checker like mypy?
mypy: a static analysis tool that reads your annotations and flags type mismatches (passing a str where an int is expected) before runtime, catching a class of bugs early in CI.
5 / 5
What does the Any type signify?
Any: annotating something as Any tells the checker to skip verification there — it is compatible with everything. Overusing it defeats the purpose of typing, so it is reserved for genuinely dynamic values.