MemotivaType hints and typing

What is the difference between dunder annotations and runtime types?

Type hints and typing

Audio flashcard · 0:16

Nortren·

What is the difference between dunder annotations and runtime types?

0:16

Type hints are stored as strings or as actual type objects in dunder annotations on functions and classes. By default they are not enforced at runtime. Libraries like Pydantic and dataclasses can use dunder annotations to perform runtime validation or to generate behavior, blurring the line between hints and types.
docs.python.org