class documentation

class ExpandSignatures(Visitor): (source)

View In Hierarchy

Expand to Cartesian product of parameter types. For example, this transforms def f(x: Union[int, float], y: Union[int, float]) -> Union[str, unicode] to def f(x: int, y: int) -> Union[str, unicode] def f(x: int, y: float) -> Union[str, unicode] def f(x: float, y: int) -> Union[str, unicode] def f(x: float, y: float) -> Union[str, unicode] The expansion by this class is typically *not* an optimization. But it can be the precursor for optimizations that need the expanded signatures, and it can simplify code generation, e.g. when generating type declarations for a type inferencer.

Method VisitFunction Rebuild the function with the new signatures.

Inherited from Visitor:

Method __init__ Undocumented
Method Enter Undocumented
Method Leave Undocumented
Method Visit Undocumented
Class Variable old_node Undocumented
Class Variable unchecked_node_names Undocumented
Class Variable visits_all_node_types Undocumented
Instance Variable enter_functions Undocumented
Instance Variable leave_functions Undocumented
Instance Variable visit_class_names Undocumented
Instance Variable visit_functions Undocumented
Class Variable _visitor_functions_cache Undocumented
def VisitFunction(self, f): (source)

Rebuild the function with the new signatures. This is called after its children (i.e. when VisitSignature has already converted each signature into a list) and rebuilds the function using the new signatures. Arguments: f: A pytd.Function instance. Returns: Function with the new signatures.