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​_default Undocumented
Method can​_be​_true​_default 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
def __eq__(self, other): (source)

Undocumented

Parameters
other:objectUndocumented
Returns
boolUndocumented
def __hash__(self): (source)

Undocumented

Returns
intUndocumented
def __init__(self, literal_value, base_type_name, line=-1, column=-1, note=None): (source)

Undocumented

Parameters
literal​_value:Optional[LiteralValue]Undocumented
base​_type​_name:strUndocumented
line:intUndocumented
column:intUndocumented
note:Optional[str]Undocumented
def accept(self, visitor): (source)

Undocumented

Parameters
visitor:TypeVisitor[T]Undocumented
Returns
TUndocumented
def serialize(self): (source)

Undocumented

Returns
JsonDictUndocumented
def simple_name(self): (source)

Undocumented

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

Undocumented

base_type_name = (source)

Undocumented

literal_value = (source)

Undocumented

note = (source)

Undocumented