class documentation

class InferenceContext: (source)

View In Hierarchy

Provide context for inference. Store already inferred nodes to save time Account for already visited nodes to stop infinite recursion

Method __init__ Undocumented
Method __str__ Undocumented
Method clone Clone inference path.
Method nodes_inferred.setter Undocumented
Method push Push node into inference path.
Method restore_path Undocumented
Class Variable __slots__ Undocumented
Class Variable max_inferred Undocumented
Instance Variable boundnode :type: optional[NodeNG]
Instance Variable callcontext The call arguments and keywords for the given context.
Instance Variable constraints The constraints on nodes.
Instance Variable extra_context :type: dict(NodeNG, Context)
Instance Variable lookupname The original name of the node.
Instance Variable path :type: set(tuple(NodeNG, optional(str)))
Property inferred Inferred node contexts to their mapped results.
Property nodes_inferred Number of nodes inferred in this context and all its clones/descendents.
Instance Variable _nodes_inferred Undocumented
def __init__(self, path=None, nodes_inferred: list[int]|None = None): (source)

Undocumented

def __str__(self) -> str: (source)

Undocumented

def clone(self) -> InferenceContext: (source)

Clone inference path. For example, each side of a binary operation (BinOp) starts with the same context but diverge as each side is inferred so the InferenceContext will need be cloned

@nodes_inferred.setter
def nodes_inferred(self, value: int): (source)

Undocumented

def push(self, node) -> bool: (source)

Push node into inference path. :return: Whether node is already in context path. Allows one to see if the given node has already been looked at for this inference context

Undocumented

__slots__: tuple[str, ...] = (source)

Undocumented

max_inferred: int = (source)

Undocumented

boundnode = (source)

:type: optional[NodeNG] The bound node of the given context e.g. the bound node of object.__new__(cls) is the object node

The call arguments and keywords for the given context.

The constraints on nodes.

extra_context: dict = (source)

:type: dict(NodeNG, Context) Context that needs to be passed down through call stacks for call arguments

lookupname: str|None = (source)

The original name of the node. e.g. foo = 1 The inference of 'foo' is nodes.Const(1) but the lookup name is 'foo'

:type: set(tuple(NodeNG, optional(str))) Path of visited nodes and their lookupname Currently this key is ``(node, context.lookupname)``

Inferred node contexts to their mapped results. Currently the key is ``(node, lookupname, callcontext, boundnode)`` and the value is tuple of the inferred results

@property
nodes_inferred: int = (source)

Number of nodes inferred in this context and all its clones/descendents. Wrap inner value in a mutable cell to allow for mutating a class variable in the presence of __slots__

_nodes_inferred: list[int] = (source)

Undocumented