class documentation

class RawExpressionType(ProperType): (source)

View In Hierarchy

A synthetic type representing some arbitrary expression that does not cleanly translate into a type. This synthetic type is only used at the beginning stages of semantic analysis and should be completely removing during the process for mapping UnboundTypes to actual types: we either turn it into a LiteralType or an AnyType. For example, suppose `Foo[1]` is initially represented as the following: UnboundType( name='Foo', args=[ RawExpressionType(value=1, base_type_name='builtins.int'), ], ) As we perform semantic analysis, this type will transform into one of two possible forms. If 'Foo' was an alias for 'Literal' all along, this type is transformed into: LiteralType(value=1, fallback=int_instance_here) Alternatively, if 'Foo' is an unrelated class, we report an error and instead produce something like this: Instance(type=typeinfo_for_foo, args=[AnyType(TypeOfAny.from_error)) If the "note" field is not None, the provided note will be reported alongside the error at this point. Note: if "literal_value" is None, that means this object is representing some expression that cannot possibly be a parameter of Literal[...]. For example, "Foo[3j]" would be represented as: UnboundType( name='Foo', args=[ RawExpressionType(value=None, base_type_name='builtins.complex'), ], )

Method __eq__ Undocumented
Method __hash__ Undocumented
Method __init__ Undocumented
Method accept Undocumented
Method serialize Undocumented
Method simple_name Undocumented
Class Variable __slots__ Undocumented
Instance Variable base_type_name Undocumented
Instance Variable literal_value Undocumented
Instance Variable note Undocumented

Inherited from Type (via ProperType):

Class Method deserialize Undocumented
Method __repr__ Undocumented
Method can_be_false.setter Undocumented
Method can_be_false_default Undocumented
Method can_be_true.setter Undocumented
Method can_be_true_default Undocumented
Method is_singleton_type 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
def __eq__(self, other: object) -> bool: (source)

Undocumented

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

Undocumented

def __init__(self, literal_value: LiteralValue|None, base_type_name: str, line: int = -1, column: int = -1, note: str|None = None): (source)

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

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

Undocumented

base_type_name = (source)

Undocumented

literal_value = (source)

Undocumented

Undocumented