class LateAnnotation: (source)
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 |
Flattens the expression into a legal variable name if necessary. |
Method | get |
Undocumented |
Method | instantiate |
Instantiate the pointed-to class, or record a placeholder instance. |
Method | is |
Undocumented |
Method | is |
Check whether this is a recursive type. |
Method | resolve |
Resolve the late annotation. |
Method | set |
Undocumented |
Method | to |
Undocumented |
Method | unflatten |
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 |
Undocumented |
Instance Variable | _imports |
Undocumented |
Instance Variable | _type |
Undocumented |
Instance Variable | _unresolved |
Undocumented |
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.