module documentation

Undocumented

Class InferenceResult Object for every result to `node.infer()`
Class MultiInferenceResult Merging of multiple inference result into one
Class UseDefaultInferenceOnce Undocumented
Class UseInferenceDefault Undocumented
Class UseInferredAttr Undocumented
Function base_infer using use_def chain info to infer the value
Function cache_yield_different Undocumented
Function calc_compare return the result of comp_list and op_list, assuming comp_list[0] is left, and all value in comp_list is constant
Function const_factory return nodes equivalent of const value. Will yield all combination of the content of the list
Function container_factory Undocumented
Function convert_to_inferred Undocumented
Function extract_const Undocumented
Function extract_const_base Undocumented
Function extract_const_const Undocumented
Function extract_const_dict Undocumented
Function extract_const_end Undocumented
Function extract_const_sequence Undocumented
Function getitem_dict Undocumented
Function getitem_sequence Undocumented
Function infer inference entry point
Function infer_arg Undocumented
Function infer_assignment infer variable that is being assigned (AssignName and AssignAttribute
Function infer_attribute Undocumented
Function infer_augassign E.g. a += 2 inferring this node will yield the value of `a`
Function infer_binop Undocumented
Function infer_bool Undocumented
Function infer_boolop - 'and' and 'or' evaluates expression from left to right. - with and, if all values are True, returns the last evaluated value. If any value is false, returns the first one. - or returns the first True value...
Function infer_call Undocumented
Function infer_compare Undocumented
Function infer_const_bin_op Undocumented
Function infer_const_bool Undocumented
Function infer_const_builtins Undocumented
Function infer_const_comp_op Undocumented
Function infer_const_unaryop Undocumented
Function infer_container_bin_op Undocumented
Function infer_container_builtins Undocumented
Function infer_dict_bool Undocumented
Function infer_end Undocumented
Function infer_formattedvalue Undocumented
Function infer_function_def Undocumented
Function infer_global_name Infer a name object that look at the global scope
Function infer_ifexp running: 1 if x else 2 will yield 1, 2
Function infer_import Undocumented
Function infer_index Undocumented
Function infer_inst_bin_op Undocumented
Function infer_inst_bool reference: https://docs.python.org/3/reference/datamodel.html#object.__bool__ First we'll try __bool__, if the method does not exist, we'll try __len__, and it's True if it return non zero. The instance is True when both of the method doesn't exist...
Function infer_inst_builtins Undocumented
Function infer_inst_comp_op Undocumented
Function infer_inst_unaryop Undocumented
Function infer_joinedstr Undocumented
Function infer_killvarcall Infer the latest KILL variable of the func that is called
Function infer_lambda_return_value Undocumented
Function infer_name Undocumented
Function infer_phi Undocumented
Function infer_return_value Undocumented
Function infer_sequence Undocumented
Function infer_sequence_bool Undocumented
Function infer_slice Undocumented
Function infer_subscript Undocumented
Function infer_temp_instance try to get the instance from arg that passed in. E.g. def foo(a): return a.b.c This will create temp instance (i.e. UselessStub) for a.b When inferring the real value though, the real instance (a.b) is needed and can get from arguments that are passing in.
Function infer_typestub Undocumented
Function infer_unaryop Undocumented
Function inference_transform_wrapper should return a transform function that change node._explicit_inference
Function limit_inference Limit inference amount. Limit inference amount to help with performance issues with exponentially exploding possible results. :param iterator: the inference iterator :type iterator: Iterator(BaseNode) :param size: Maximum mount of nodes yielded plus an Uninferable at the end if limit reached :type size: int :yields: A possibly modified generator :rtype param: Iterable...
Function reverse_container_factory Undocumented
Constant CONST_MAP Undocumented
Constant CONTAINER_MAP Undocumented
Constant MANAGER Undocumented
Function _bin_op_methods To yield different combination of dunder method calling
Function _comp_op_methods To yield different combination of dunder method calling In compare node, we don't care about the type since there is no reflected dunder method in comparison op.
Function _infer_binary_op Undocumented
Function _infer_unaryop Undocumented
Function _invoke_op_inference find the dunder method and call _infer_binop
Function _make_call_from_dunder_method Undocumented
Function _make_call_from_func Undocumented
def base_infer(self, context=context_mod.context_ins, inferred_attr=None): (source)

using use_def chain info to infer the value

def cache_yield_different(func): (source)

Undocumented

def calc_compare(comp_list, op_list, context): (source)

return the result of comp_list and op_list, assuming comp_list[0] is left, and all value in comp_list is constant

def const_factory(value, *args, **kwargs): (source)

return nodes equivalent of const value. Will yield all combination of the content of the list

def container_factory(container): (source)

Undocumented

def convert_to_inferred(inferred): (source)

Undocumented

def extract_const(self, context=None): (source)

Undocumented

def extract_const_base(self, context=None): (source)

Undocumented

def extract_const_const(self, context=None): (source)

Undocumented

def extract_const_dict(self, context=None): (source)

Undocumented

def extract_const_end(self, context=context_mod.context_ins): (source)

Undocumented

def extract_const_sequence(self, context=None, ctype=list): (source)

Undocumented

def getitem_dict(self, index, context=context_mod.context_ins): (source)

Undocumented

def getitem_sequence(self, index, context=context_mod.context_ins): (source)

Undocumented

inference entry point

def infer_arg(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_assignment(self, context=context_mod.context_ins, inferred_attr=None): (source)

infer variable that is being assigned (AssignName and AssignAttribute

def infer_attribute(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_augassign(self, context=context_mod.context_ins, inferred_attr=None): (source)

E.g. a += 2 inferring this node will yield the value of `a`

def infer_binop(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_bool(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_boolop(self, context=context_mod.context_ins, inferred_attr=None): (source)

- 'and' and 'or' evaluates expression from left to right. - with and, if all values are True, returns the last evaluated value. If any value is false, returns the first one. - or returns the first True value. If all are False, returns the last value ALl the following elements are False: [/] = implemented, [x] = pending. [/] None [/] False [/] 0 (whatever type from integer, float to complex) [/] Empty collections: “”, (), [], {} [x] Objects from classes that have the special method __nonzero__ [x] Objects from classes that implements __len__ to return False or zero

def infer_call(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_compare(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_const_bin_op(self, op, other, _, context=None, self_result=None): (source)

Undocumented

def infer_const_bool(self, context=context_mod.context_ins): (source)

Undocumented

def infer_const_builtins(self, builtin_func, context): (source)

Undocumented

Parameters
builtin_func:strUndocumented
contextUndocumented
def infer_const_comp_op(self, op, other, _, context=None, self_result=None): (source)

Undocumented

def infer_const_unaryop(self, op, _, context): (source)

Undocumented

def infer_container_bin_op(self, op, other, _, context=context_mod.context_ins, self_result=None): (source)

Undocumented

def infer_container_builtins(self, builtin_func, context): (source)

Undocumented

Parameters
builtin_func:strUndocumented
contextUndocumented
def infer_dict_bool(self, context=context_mod.context_ins): (source)

Undocumented

def infer_end(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

@decorators.yield_at_least_once((lambda x: InferenceResult.load_result(nodes.Uninferable(x))))
def infer_formattedvalue(node, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

Parameters
node:nodes.FormattedValueUndocumented
contextUndocumented
inferred_attrUndocumented
def infer_function_def(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_global_name(self, context=context_mod.context_ins, inferred_attr=None): (source)

Infer a name object that look at the global scope

def infer_ifexp(self, context=context_mod.context_ins, inferred_attr=None): (source)

running: 1 if x else 2 will yield 1, 2

def infer_import(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_index(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_inst_bin_op(self, _, other, method_name, context=context_mod.context_ins, self_result=None): (source)

Undocumented

def infer_inst_bool(self, context=context_mod.context_ins): (source)

reference: https://docs.python.org/3/reference/datamodel.html#object.__bool__ First we'll try __bool__, if the method does not exist, we'll try __len__, and it's True if it return non zero. The instance is True when both of the method doesn't exist

def infer_inst_builtins(self, builtin_func, context): (source)

Undocumented

Parameters
builtin_func:strUndocumented
contextUndocumented
def infer_inst_comp_op(self, op, other, method_name, context=context_mod.context_ins, self_result=None): (source)

Undocumented

def infer_inst_unaryop(self, _, method_name, context=context_mod.context_ins): (source)

Undocumented

@decorators.yield_at_least_once((lambda x: InferenceResult.load_result(nodes.Uninferable(x))))
def infer_joinedstr(node, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

Parameters
node:nodes.JoinedStrUndocumented
contextUndocumented
inferred_attrUndocumented
def infer_killvarcall(self, context=context_mod.context_ins, inferred_attr=None): (source)

Infer the latest KILL variable of the func that is called

def infer_lambda_return_value(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_name(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_phi(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_return_value(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_sequence(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_sequence_bool(self, context=context_mod.context_ins): (source)

Undocumented

def infer_slice(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_subscript(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_temp_instance(self, context=context_mod.context_ins, inferred_attr=None): (source)

try to get the instance from arg that passed in. E.g. def foo(a): return a.b.c This will create temp instance (i.e. UselessStub) for a.b When inferring the real value though, the real instance (a.b) is needed and can get from arguments that are passing in.

def infer_typestub(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def infer_unaryop(self, context=context_mod.context_ins, inferred_attr=None): (source)

Undocumented

def inference_transform_wrapper(infer_function): (source)

should return a transform function that change node._explicit_inference

def limit_inference(iterator, size): (source)

Limit inference amount. Limit inference amount to help with performance issues with exponentially exploding possible results. :param iterator: the inference iterator :type iterator: Iterator(BaseNode) :param size: Maximum mount of nodes yielded plus an Uninferable at the end if limit reached :type size: int :yields: A possibly modified generator :rtype param: Iterable

def reverse_container_factory(container): (source)

Undocumented

CONTAINER_MAP = (source)

Undocumented

Value
{set: nodes.Set, list: nodes.List, tuple: nodes.Tuple}
MANAGER = (source)

Undocumented

Value
manager.AstManager()
def _bin_op_methods(left, right, op, context): (source)

To yield different combination of dunder method calling

Parameters
left:InferenceResultUndocumented
right:InferenceResultUndocumented
opUndocumented
contextUndocumented
def _comp_op_methods(left, right, op, context): (source)

To yield different combination of dunder method calling In compare node, we don't care about the type since there is no reflected dunder method in comparison op.

Parameters
left:InferenceResultUndocumented
right:InferenceResultUndocumented
opUndocumented
contextUndocumented
def _infer_binary_op(left, right, op, context): (source)

Undocumented

Parameters
left:InferenceResultUndocumented
right:InferenceResultUndocumented
opUndocumented
contextUndocumented
def _infer_unaryop(op, val, context=None): (source)

Undocumented

Parameters
op:strUndocumented
val:InferenceResultUndocumented
contextUndocumented
def _invoke_op_inference(instance, method_name, other, op, infer_method_repr, context): (source)

find the dunder method and call _infer_binop

Parameters
instance:InferenceResultUndocumented
method_nameUndocumented
other:InferenceResultUndocumented
opUndocumented
infer_method_reprUndocumented
contextUndocumented
@contextlib.contextmanager
def _make_call_from_dunder_method(instance, dunder_method, context, *args): (source)

Undocumented

def _make_call_from_func(function, *args): (source)

Undocumented