Visitor for verifying containers. Every container (except typing.Generic) must inherit from typing.Generic and have an explicitly parameterized base that is also a container. The parameters on typing.Generic must all be TypeVar instances. A container must have at most as many parameters as specified in its template. Raises: ContainerError: If a problematic container definition is encountered.
Method |
|
Undocumented |
Method |
|
Check for conflicting type parameter values in the class's bases. |
Method |
|
Verify a pytd.GenericType. |
Method |
|
Undocumented |
Method | _ |
Get a lookup map for the generic bases of a class. |
Method | _ |
Check if the types are compatible. |
Method | _ |
Update the given mapping of parameter names to values. |
Inherited from Visitor
:
Method | __init__ |
Undocumented |
Method |
|
Undocumented |
Method |
|
Undocumented |
Method |
|
Undocumented |
Class Variable | old |
Undocumented |
Class Variable | unchecked |
Undocumented |
Class Variable | visits |
Undocumented |
Instance Variable | enter |
Undocumented |
Instance Variable | leave |
Undocumented |
Instance Variable | visit |
Undocumented |
Instance Variable | visit |
Undocumented |
Class Variable | _visitor |
Undocumented |
Get a lookup map for the generic bases of a class. Gets a map from a pytd.ClassType to the list of pytd.GenericType bases of the node that have that class as their base. This method does depth-first traversal of the bases, which ensures that the order of elements in each list is consistent with the node's MRO. Args: node: A pytd.Class node. Returns: A pytd.ClassType -> List[pytd.GenericType] map.
Check if the types are compatible. It is used to handle the case: class A(Sequence[A]): pass class B(A, Sequence[B]): pass class C(B, Sequence[C]): pass In class `C`, the type parameter `_T` of Sequence could be `A`, `B` or `C`. Next we will check they have a linear inheritance relationship: `A` -> `B` -> `C`. Args: type_params: The class type params. Returns: True if all the types are compatible.