module documentation
Various helper utilities.
Function | class |
Get the value as an index for the given instance. |
Function | has |
Return true if all base classes of a class could be inferred. |
Function | is |
Check if type1 is a subtype of type2. |
Function | is |
Check if type2 is a supertype of type1. |
Function | object |
Check if a node 'isinstance' any node in class_or_seq |
Function | object |
Check if a type is a subclass of any node in class_or_seq |
Function | object |
Infer length of given node object |
Function | object |
Obtain the type of the given node |
Function | safe |
Return the inferred value for the given node. |
Function | _build |
Undocumented |
Function | _function |
Undocumented |
Function | _object |
Undocumented |
Function | _object |
Undocumented |
Function | _type |
Undocumented |
Get the value as an index for the given instance.
If an instance provides an __index__ method, then it can be used in some scenarios where an integer is expected, for instance when multiplying or subscripting a list.
Check if a node 'isinstance' any node in class_or_seq
Parameters | |
node | A given node |
class | Union[nodes.NodeNG, Sequence[nodes.NodeNG]] |
context | Undocumented |
Returns | |
bool | Undocumented |
Raises | |
AstroidTypeError | if the given classes_or_seq are not types |
Check if a type is a subclass of any node in class_or_seq
Parameters | |
node | A given node |
class | Union[Nodes.NodeNG, Sequence[nodes.NodeNG]] |
context | Undocumented |
Returns | |
bool | Undocumented |
Raises | |
AstroidTypeError | if the given classes_or_seq are not types |
AstroidError | if the type of the given node cannot be inferred or its type's mro doesn't work |
Infer length of given node object
Parameters | |
node | Node to infer length of |
context | Undocumented |
Returns | |
Integer length of node | Undocumented |
Raises | |
AstroidTypeError | If an invalid node is returned from __len__ method or no __len__ method exists |
InferenceError | If the given node cannot be inferred or if multiple nodes are inferred or if the code executed in python would result in a infinite recursive check for length |
Obtain the type of the given node
This is used to implement the type builtin, which means that it's used for inferring type calls, as well as used in a couple of other places in the inference. The node will be inferred first, so this function can support all sorts of objects, as long as they support inference.