class documentation

class CallSite: (source)

View In Hierarchy

Class for understanding arguments passed into a call site

It needs a call context, which contains the arguments and the keyword arguments that were passed into a given call site. In order to infer what an argument represents, call infer_argument with the corresponding function node and the argument name.

Parameters
callcontextAn instance of astroid.context.CallContext, that holds the arguments for the call site.
argument​_context​_mapAdditional contexts per node, passed in from astroid.context.Context.extra_context
contextAn instance of astroid.context.Context.
Class Method from​_call Get a CallSite object from the given Call node.
Method __init__ Undocumented
Method has​_invalid​_arguments Check if in the current CallSite were passed invalid arguments
Method has​_invalid​_keywords Check if in the current CallSite were passed invalid keyword arguments
Method infer​_argument infer a function argument value according to the call context
Instance Variable argument​_context​_map Undocumented
Instance Variable duplicated​_keywords Undocumented
Instance Variable keyword​_arguments Undocumented
Instance Variable positional​_arguments Undocumented
Method _unpack​_args Undocumented
Method _unpack​_keywords Undocumented
Instance Variable _unpacked​_args Undocumented
Instance Variable _unpacked​_kwargs Undocumented
@classmethod
def from_call(cls, call_node, context=None): (source)

Get a CallSite object from the given Call node.

context will be used to force a single inference path.

Parameters
call​_nodeUndocumented
context:Optional[Context]Undocumented
def __init__(self, callcontext, argument_context_map=None, context=None): (source)

Undocumented

Parameters
callcontext:CallContextUndocumented
argument​_context​_mapUndocumented
contextUndocumented
def has_invalid_arguments(self): (source)

Check if in the current CallSite were passed invalid arguments

This can mean multiple things. For instance, if an unpacking of an invalid object was passed, then this method will return True. Other cases can be when the arguments can't be inferred by astroid, for example, by passing objects which aren't known statically.

def has_invalid_keywords(self): (source)

Check if in the current CallSite were passed invalid keyword arguments

For instance, unpacking a dictionary with integer keys is invalid (**{1:2}), because the keys must be strings, which will make this method to return True. Other cases where this might return True if objects which can't be inferred were passed.

def infer_argument(self, funcnode, name, context): (source)

infer a function argument value according to the call context

Arguments:
funcnode: The function being called. name: The name of the argument whose value is being inferred. context: Inference context object
argument_context_map = (source)

Undocumented

duplicated_keywords = (source)

Undocumented

keyword_arguments = (source)

Undocumented

positional_arguments = (source)

Undocumented

def _unpack_args(self, args, context=None): (source)

Undocumented

def _unpack_keywords(self, keywords, context=None): (source)

Undocumented

_unpacked_args = (source)

Undocumented

_unpacked_kwargs = (source)

Undocumented