class InferenceContext: (source)
Constructor: InferenceContext(path, nodes_inferred)
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 |
Undocumented |
Method | push |
Push node into inference path |
Method | restore |
Undocumented |
Class Variable | __slots__ |
Undocumented |
Class Variable | max |
Undocumented |
Instance Variable | boundnode |
The bound node of the given context |
Instance Variable | callcontext |
The call arguments and keywords for the given context |
Instance Variable | extra |
Context that needs to be passed down through call stacks for call arguments |
Instance Variable | lookupname |
The original name of the node |
Instance Variable | path |
Path of visited nodes and their lookupname |
Property | inferred |
Inferred node contexts to their mapped results |
Property | nodes |
Number of nodes inferred in this context and all its clones/descendents |
Instance Variable | _nodes |
Undocumented |
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
Push node into inference path
Allows one to see if the given node has already been looked at for this inference context
Returns | |
bool | True if node is already in context path else False |
The original name of the node
e.g. foo = 1 The inference of 'foo' is nodes.Const(1) but the lookup name is 'foo'
inferred:
MutableMapping[ tuple[ NodeNG, str | None, str | None, str | None], Sequence[ NodeNG]]
=
(source)
¶
Inferred node contexts to their mapped results
Currently the key is (node, lookupname, callcontext, boundnode) and the value is tuple of the inferred results