class documentation

class LateAnnotation: (source)

View In Hierarchy

A late annotation. A late annotation stores a string expression and a snapshot of the VM stack at the point where the annotation was introduced. Once the expression is resolved, the annotation pretends to be the resolved type; before that, it pretends to be an unsolvable. This effect is achieved by delegating attribute lookup with __getattribute__. Note that for late annotation x, `isinstance(x, ...)` and `x.__class__` will use the type that x is pretending to be; `type(x)` will reveal x's true type. Use `x.is_late_annotation()` to check whether x is a late annotation.

Method __eq__ Undocumented
Method __getattribute__ Undocumented
Method __hash__ Undocumented
Method __init__ Undocumented
Method __repr__ Undocumented
Method __setattr__ Undocumented
Method flatten_expr Flattens the expression into a legal variable name if necessary.
Method get_special_attribute Undocumented
Method instantiate Instantiate the pointed-to class, or record a placeholder instance.
Method is_late_annotation Undocumented
Method is_recursive Check whether this is a recursive type.
Method resolve Resolve the late annotation.
Method set_type Undocumented
Method to_variable Undocumented
Method unflatten_expr Unflattens a flattened expression.
Instance Variable ctx Undocumented
Instance Variable expr Undocumented
Instance Variable resolved Undocumented
Instance Variable stack Undocumented
Constant _RESOLVING Undocumented
Instance Variable _attribute_names Undocumented
Instance Variable _imports Undocumented
Instance Variable _type Undocumented
Instance Variable _unresolved_instances Undocumented
def __eq__(self, other): (source)

Undocumented

def __getattribute__(self, name): (source)

Undocumented

def __hash__(self): (source)

Undocumented

def __init__(self, expr, stack, ctx, *, imports=None): (source)

Undocumented

def __repr__(self): (source)

Undocumented

def __setattr__(self, name, value): (source)

Undocumented

def flatten_expr(self): (source)

Flattens the expression into a legal variable name if necessary. Pytype stores parameterized recursive types in intermediate variables. If self is such a type, this method flattens self.expr into a string that can serve as a variable name. For example, 'MyRecursiveAlias[int, str]' is flattened into '_MyRecursiveAlias_LBAR_int_COMMA_str_RBAR'. Returns: If self is a parameterized recursive type, a flattened version of self.expr that is a legal variable name. Otherwise, self.expr unchanged.

def get_special_attribute(self, node, name, valself): (source)

Undocumented

def instantiate(self, node, container=None): (source)

Instantiate the pointed-to class, or record a placeholder instance.

def is_late_annotation(self): (source)

Undocumented

def is_recursive(self): (source)

Check whether this is a recursive type.

def resolve(self, node, f_globals, f_locals): (source)

Resolve the late annotation.

def set_type(self, typ): (source)

Undocumented

def to_variable(self, node): (source)

Undocumented

def unflatten_expr(self): (source)

Unflattens a flattened expression.

Undocumented

Undocumented

resolved: bool = (source)

Undocumented

Undocumented

_RESOLVING = (source)

Undocumented

Value
object()
_attribute_names = (source)

Undocumented

_imports = (source)

Undocumented

Undocumented

_unresolved_instances = (source)

Undocumented