class LiteralType(ProperType): (source)
The type of a Literal instance. Literal[Value]
A Literal always consists of:
For example, 'Literal[42]' is represented as 'LiteralType(value=42, fallback=instance_of_int)'
As another example, Literal[Color.RED] (where Color is an enum) is
represented as `LiteralType(value="RED", fallback=instance_of_color)'.
| Class Method | deserialize |
Undocumented |
| Method | __eq__ |
Undocumented |
| Method | __hash__ |
Undocumented |
| Method | __init__ |
Undocumented |
| Method | accept |
Undocumented |
| Method | can_be_false_default |
Undocumented |
| Method | can_be_true_default |
Undocumented |
| Method | is_enum_literal |
Undocumented |
| Method | serialize |
Undocumented |
| Method | value_repr |
Returns the string representation of the underlying type. |
| Class Variable | __slots__ |
Undocumented |
| Instance Variable | fallback |
Undocumented |
| Instance Variable | value |
Undocumented |
Inherited from Type (via ProperType):
| Method | __repr__ |
Undocumented |
| Instance Variable | can_be_false |
Undocumented |
| Instance Variable | can_be_true |
Undocumented |
Inherited from Context (via ProperType, Type):
| Method | get_column |
Don't use. Use x.column. |
| Method | get_line |
Don't use. Use x.line. |
| Method | set_line |
If target is a node, pull line (and column) information into this node. If column is specified, this will override any column information coming from a node. |
| Instance Variable | column |
Undocumented |
| Instance Variable | end_line |
Undocumented |
| Instance Variable | line |
Undocumented |
mypy.types.Type.deserializeUndocumented
| Parameters | |
data:JsonDict | Undocumented |
| Returns | |
LiteralType | Undocumented |
mypy.types.Type.__init__Undocumented
| Parameters | |
value:LiteralValue | Undocumented |
fallback:Instance | Undocumented |
line:int | Undocumented |
column:int | Undocumented |
mypy.types.Type.acceptUndocumented
| Parameters | |
visitor:TypeVisitor[ | Undocumented |
| Returns | |
T | Undocumented |