class documentation

class LiteralType(ProperType): (source)

View In Hierarchy

The type of a Literal instance. Literal[Value] A Literal always consists of: 1. A native Python object corresponding to the contained inner value 2. A fallback for this Literal. The fallback also corresponds to the parent type this Literal subtypes. 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 is_singleton_type 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
Instance Variable _hash Undocumented

Inherited from Type (via ProperType):

Method __repr__ Undocumented
Method can_be_false.setter Undocumented
Method can_be_true.setter Undocumented
Property can_be_false Undocumented
Property can_be_true Undocumented
Instance Variable _can_be_false Undocumented
Instance Variable _can_be_true Undocumented

Inherited from Context (via ProperType, Type):

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_column Undocumented
Instance Variable end_line Undocumented
Instance Variable line Undocumented
@classmethod
def deserialize(cls, data: JsonDict) -> LiteralType: (source)

Undocumented

def __eq__(self, other: object) -> bool: (source)

Undocumented

def __hash__(self) -> int: (source)

Undocumented

def __init__(self, value: LiteralValue, fallback: Instance, line: int = -1, column: int = -1): (source)

Undocumented

def accept(self, visitor: TypeVisitor[T]) -> T: (source)

Undocumented

def can_be_false_default(self) -> bool: (source)

Undocumented

def can_be_true_default(self) -> bool: (source)

Undocumented

def is_enum_literal(self) -> bool: (source)

Undocumented

def is_singleton_type(self) -> bool: (source)

Undocumented

def serialize(self) -> JsonDict|str: (source)

Undocumented

def value_repr(self) -> str: (source)

Returns the string representation of the underlying type. This function is almost equivalent to running `repr(self.value)`, except it includes some additional logic to correctly handle cases where the value is a string, byte string, a unicode string, or an enum.

__slots__: tuple[str, ...] = (source)

Undocumented

fallback = (source)

Undocumented

Undocumented

Undocumented