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 :meth:`infer_argument` with the corresponding function node and the argument name. :param callcontext: An instance of :class:`astroid.context.CallContext`, that holds the arguments for the call site. :param argument_context_map: Additional contexts per node, passed in from :attr:`astroid.context.Context.extra_context` :param context: An instance of :class:`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: InferenceContext|None = None): (source)

Get a CallSite object from the given Call node. context will be used to force a single inference path.

def __init__(self, callcontext: CallContext, argument_context_map=None, context: InferenceContext|None = None): (source)

Undocumented

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) -> bool: (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: set[str] = (source)

Undocumented

keyword_arguments = (source)

Undocumented

positional_arguments = (source)

Undocumented

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

Undocumented

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

Undocumented

_unpacked_args = (source)

Undocumented

_unpacked_kwargs = (source)

Undocumented