class documentation

A PyTD function type (signature). This represents instances of functions with specific arguments and return type.

Method __init__ Undocumented
Method __repr__ Undocumented
Method call_with_args Call this signature. Used by PyTDFunction.
Method get_positional_names Undocumented
Method set_defaults Set signature's default arguments. Requires rebuilding PyTD signature.
Method substitute_formal_args Substitute matching args into this signature. Used by PyTDFunction.
Instance Variable mutated_type_parameters Undocumented
Instance Variable name Undocumented
Instance Variable param_types Undocumented
Instance Variable pytd_sig Undocumented
Instance Variable signature Undocumented
Class Method _collect_mutated_parameters Undocumented
Method _fill_in_missing_parameters Undocumented
Method _get_mutation Mutation for changing the type parameters of mutable arguments.
Method _handle_paramspec Construct a new function based on ParamSpec matching.
Method _map_args Map the passed arguments to a name->binding dictionary.
Method _paramspec_signature Undocumented

Inherited from ContextWeakrefMixin:

Class Variable __slots__ Undocumented
Instance Variable ctx_weakref Undocumented
Property ctx Undocumented
def __init__(self, name, pytd_sig, ctx): (source)
def __repr__(self): (source)

Undocumented

def call_with_args(self, node, func, arg_dict, match, ret_map): (source)

Call this signature. Used by PyTDFunction.

def get_positional_names(self): (source)

Undocumented

def set_defaults(self, defaults): (source)

Set signature's default arguments. Requires rebuilding PyTD signature. Args: defaults: An iterable of function argument defaults. Returns: Self with an updated signature.

def substitute_formal_args(self, node, args, match_all_views, keep_all_views): (source)

Substitute matching args into this signature. Used by PyTDFunction.

mutated_type_parameters: dict = (source)

Undocumented

Undocumented

param_types = (source)

Undocumented

pytd_sig = (source)

Undocumented

signature = (source)

Undocumented

@classmethod
def _collect_mutated_parameters(cls, typ, mutated_type): (source)

Undocumented

def _fill_in_missing_parameters(self, node, args, arg_dict): (source)

Undocumented

def _get_mutation(self, node, arg_dict, subst, retvar): (source)

Mutation for changing the type parameters of mutable arguments. This will adjust the type parameters as needed for pytd functions like: def append_float(x: list[int]): x = list[int or float] This is called after all the signature matching has succeeded, and we know we're actually calling this function. Args: node: The current CFG node. arg_dict: A map of strings to cfg.Variable instances. subst: Current type parameters. retvar: A variable of the return value. Returns: A list of Mutation instances. Raises: ValueError: If the pytd contains invalid information for mutated params.

def _handle_paramspec(self, node, key, ret_map): (source)

Construct a new function based on ParamSpec matching.

def _map_args(self, node, args): (source)

Map the passed arguments to a name->binding dictionary. Args: node: The current node. args: The passed arguments. Returns: A tuple of: a list of formal arguments, each a (name, abstract value) pair; a name->variable dictionary of the passed arguments. Raises: InvalidParameters: If the passed arguments don't match this signature.

def _paramspec_signature(self, callable_type, return_value, subst): (source)

Undocumented