module documentation

This module contains a set of functions to handle python protocols for nodes where it makes sense.

Function arguments_assigned_stmts Undocumented
Function assend_assigned_stmts Undocumented
Function assign_annassigned_stmts Undocumented
Function assign_assigned_stmts Undocumented
Function const_infer_binary_op Undocumented
Function excepthandler_assigned_stmts Undocumented
Function for_assigned_stmts Undocumented
Function instance_class_infer_binary_op Undocumented
Function match_as_assigned_stmts Infer MatchAs as the Match subject if it's the only MatchCase pattern else raise StopIteration to yield Uninferable.
Function match_mapping_assigned_stmts Return empty generator (return -> raises StopIteration) so inferred value is Uninferable.
Function match_star_assigned_stmts Return empty generator (return -> raises StopIteration) so inferred value is Uninferable.
Function named_expr_assigned_stmts Infer names and other nodes from an assignment expression.
Function sequence_assigned_stmts Undocumented
Function starred_assigned_stmts Arguments: self: nodes.Starred node: a node related to the current underlying Node. context: Inference context used for caching already inferred objects assign_path: A list of indices, where each index specifies what item to fetch from the inference results.
Function tl_infer_binary_op Infer a binary operation on a tuple or list.
Function with_assigned_stmts Infer names and other nodes from a *with* statement.
Constant AUGMENTED_OP_METHOD Undocumented
Constant BIN_OP_IMPL Undocumented
Constant BIN_OP_METHOD Undocumented
Constant REFLECTED_BIN_OP_METHOD Undocumented
Constant UNARY_OP_METHOD Undocumented
Variable objects Undocumented
Variable raw_building Undocumented
Function _arguments_infer_argname Undocumented
Function _augmented_name Undocumented
Function _filter_uninferable_nodes Undocumented
Function _infer_context_manager Undocumented
Function _infer_unary_op Perform unary operation on `obj`, unless it is `NotImplemented`.
Function _multiply_seq_by_int Undocumented
Function _reflected_name Undocumented
Function _resolve_assignment_parts Recursive function to resolve multiple assignments.
Function _resolve_looppart Recursive function to resolve multiple assignments on loops.
Constant _CONTEXTLIB_MGR Undocumented
Constant _UNARY_OPERATORS Undocumented
Type Variable _TupleListNodeT Undocumented
def arguments_assigned_stmts(self: nodes.Arguments, node: node_classes.AssignedStmtsPossibleNode = None, context: InferenceContext|None = None, assign_path: list[int]|None = None) -> Any: (source)

Undocumented

Undocumented

def assign_annassigned_stmts(self: nodes.AnnAssign, node: node_classes.AssignedStmtsPossibleNode = None, context: InferenceContext|None = None, assign_path: list[int]|None = None) -> Any: (source)

Undocumented

Undocumented

Infer MatchAs as the Match subject if it's the only MatchCase pattern else raise StopIteration to yield Uninferable.

Return empty generator (return -> raises StopIteration) so inferred value is Uninferable.

Return empty generator (return -> raises StopIteration) so inferred value is Uninferable.

Infer names and other nodes from an assignment expression.

def sequence_assigned_stmts(self: nodes.Tuple|nodes.List, node: node_classes.AssignedStmtsPossibleNode = None, context: InferenceContext|None = None, assign_path: list[int]|None = None) -> Any: (source)

Undocumented

Arguments: self: nodes.Starred node: a node related to the current underlying Node. context: Inference context used for caching already inferred objects assign_path: A list of indices, where each index specifies what item to fetch from the inference results.

Infer a binary operation on a tuple or list. The instance on which the binary operation is performed is a tuple or list. This refers to the left-hand side of the operation, so: 'tuple() + 1' or '[] + A()'

Infer names and other nodes from a *with* statement. This enables only inference for name binding in a *with* statement. For instance, in the following code, inferring `func` will return the `ContextManager` class, not whatever ``__enter__`` returns. We are doing this intentionally, because we consider that the context manager result is whatever __enter__ returns and what it is binded using the ``as`` keyword. class ContextManager(object): def __enter__(self): return 42 with ContextManager() as f: pass # ContextManager().infer() will return ContextManager # f.infer() will return 42. Arguments: self: nodes.With node: The target of the assignment, `as (a, b)` in `with foo as (a, b)`. context: Inference context used for caching already inferred objects assign_path: A list of indices, where each index specifies what item to fetch from the inference results.

AUGMENTED_OP_METHOD = (source)

Undocumented

Value
{(key + '='): _augmented_name(value) for key, value in BIN_OP_METHOD.items()}
BIN_OP_IMPL = (source)

Undocumented

Value
{'+': (lambda a, b: a + b),
 '-': (lambda a, b: a - b),
 '/': (lambda a, b: a / b),
 '//': (lambda a, b: a // b),
 '*': (lambda a, b: a * b),
 '**': (lambda a, b: a ** b),
 '%': (lambda a, b: a % b),
...
BIN_OP_METHOD: dict[str, str] = (source)

Undocumented

Value
{'+': '__add__',
 '-': '__sub__',
 '/': '__truediv__',
 '//': '__floordiv__',
 '*': '__mul__',
 '**': '__pow__',
 '%': '__mod__',
...
REFLECTED_BIN_OP_METHOD = (source)

Undocumented

Value
{key: _reflected_name(value) for key, value in BIN_OP_METHOD.items()}
UNARY_OP_METHOD: dict = (source)

Undocumented

Value
{'+': '__pos__', '-': '__neg__', '~': '__invert__', 'not': None}

Undocumented

raw_building = (source)

Undocumented

def _arguments_infer_argname(self, name: str|None, context: InferenceContext) -> Generator[InferenceResult, None, None]: (source)

Undocumented

def _augmented_name(name) -> str: (source)

Undocumented

Undocumented

def _infer_context_manager(self, mgr, context): (source)

Undocumented

def _infer_unary_op(obj: Any, op: str) -> ConstFactoryResult: (source)

Perform unary operation on `obj`, unless it is `NotImplemented`. Can raise TypeError if operation is unsupported.

def _multiply_seq_by_int(self: _TupleListNodeT, opnode: nodes.AugAssign|nodes.BinOp, other: nodes.Const, context: InferenceContext) -> _TupleListNodeT: (source)

Undocumented

def _reflected_name(name) -> str: (source)

Undocumented

def _resolve_assignment_parts(parts, assign_path, context): (source)

Recursive function to resolve multiple assignments.

def _resolve_looppart(parts, assign_path, context): (source)

Recursive function to resolve multiple assignments on loops.

_CONTEXTLIB_MGR: str = (source)

Undocumented

Value
'contextlib.contextmanager'
_UNARY_OPERATORS: dict[str, Callable[[Any], Any]] = (source)

Undocumented

Value
{'+': operator_mod.pos,
 '-': operator_mod.neg,
 '~': operator_mod.invert,
 'not': operator_mod.not_}
_TupleListNodeT = (source)

Undocumented

Value
TypeVar('_TupleListNodeT', nodes.Tuple, nodes.List)