module documentation

Representation of Python function headers and calls.

Class AbstractReturnType An abstract return type.
Class Arg Undocumented
Class Args Represents the parameters of a function call.
Class BadCall Undocumented
Class Mutation A type mutation.
Class ParamSpecMatch Match a paramspec against a sig.
Class PyTDReturnType A PyTD return type.
Class ReturnValueMixin Mixin for exceptions that hold a return node and variable.
Class Signature Representation of a Python function signature.
Exception DictKeyMissing When retrieving a key that does not exist in a dict.
Exception DuplicateKeyword E.g. an arg "x" is passed to a function as both a posarg and a kwarg.
Exception FailedFunctionCall Exception for failed function calls.
Exception InvalidParameters Exception for functions called with an incorrect parameter combination.
Exception MissingParameter E.g. a function requires parameter 'x' but 'x' isn't passed.
Exception NotCallable For objects that don't have __call__.
Exception UndefinedParameterError Function called with an undefined variable.
Exception WrongArgCount E.g. if a function expecting 4 parameters is called with 3.
Exception WrongArgTypes For functions that were called with the wrong types.
Exception WrongKeywordArgs E.g. an arg "x" is passed to a function that doesn't have an "x" param.
Function argname Get a name for an unnamed positional argument, given its position.
Function build_paramspec_signature Build a signature from a ParamSpecMatch and Callable args.
Function call_function Call a function.
Function get_signatures Gets the given function's signatures.
Function handle_typeguard Returns a variable of the return value of a typeguard function.
Function has_visible_namedarg Undocumented
Function match_all_args Call match_args multiple times to find all type errors.
Variable log Undocumented
Class _ReturnType Undocumented
Function _convert_namedargs Undocumented
Function _print Undocumented
Function _splats_to_any Undocumented
def argname(i): (source)

Get a name for an unnamed positional argument, given its position.

def build_paramspec_signature(pspec_match, r_args, return_value, ctx): (source)

Build a signature from a ParamSpecMatch and Callable args.

def call_function(ctx, node, func_var, args, fallback_to_unsolvable=True, allow_noreturn=False, strict_filter=True): (source)

Call a function. Args: ctx: The abstract context. node: The current CFG node. func_var: A variable of the possible functions to call. args: The arguments to pass. See function.Args. fallback_to_unsolvable: If the function call fails, create an unknown. allow_noreturn: Whether typing.NoReturn is allowed in the return type. strict_filter: Whether function bindings should be strictly filtered. Returns: A tuple (CFGNode, Variable). The Variable is the return value. Raises: DictKeyMissing: if we retrieved a nonexistent key from a dict and fallback_to_unsolvable is False. FailedFunctionCall: if the call fails and fallback_to_unsolvable is False.

def get_signatures(func): (source)

Gets the given function's signatures.

def handle_typeguard(node, ret: _ReturnType, first_arg, ctx, func_name=None): (source)

Returns a variable of the return value of a typeguard function. Args: node: The current node. ret: The function's return value. first_arg: The first argument to the function. ctx: The current context. func_name: Optionally, the function name, for better error messages.

def has_visible_namedarg(node, args, names): (source)

Undocumented

def match_all_args(ctx, node, func, args): (source)

Call match_args multiple times to find all type errors. Args: ctx: The abstract context. node: The current CFG node. func: An abstract function args: An Args object to match against func Returns: A tuple of (new_args, errors) where new_args = args with all incorrectly typed values set to Any errors = a list of [(type mismatch error, arg name, value)] Reraises any error that is not function.InvalidParameters

Undocumented

def _convert_namedargs(namedargs): (source)

Undocumented

def _print(t): (source)

Undocumented

def _splats_to_any(seq, ctx): (source)

Undocumented