What is a Literal type?
Type hints and typing
Audio flashcard · 0:13Nortren·
What is a Literal type?
0:13
A Literal type restricts a value to specific constants. For example, Literal of red, green, blue means the value must be exactly one of those strings. It is useful for typing flags, enums, and discriminated unions where the set of allowed values is small and known.
peps.python.org