module documentation
(source)

Various helper utilities.
Function class​_instance​_as​_index Get the value as an index for the given instance.
Function has​_known​_bases Return true if all base classes of a class could be inferred.
Function is​_subtype Check if type1 is a subtype of type2.
Function is​_supertype Check if type2 is a supertype of type1.
Function object​_isinstance Check if a node 'isinstance' any node in class_or_seq
Function object​_issubclass Check if a type is a subclass of any node in class_or_seq
Function object​_len Infer length of given node object
Function object​_type Obtain the type of the given node
Function safe​_infer Return the inferred value for the given node.
Function _build​_proxy​_class Undocumented
Function _function​_type Undocumented
Function _object​_type Undocumented
Function _object​_type​_is​_subclass Undocumented
Function _type​_check Undocumented
def class_instance_as_index(node): (source)

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.

def has_known_bases(klass, context=None): (source)
Return true if all base classes of a class could be inferred.
def is_subtype(type1, type2): (source)
Check if type1 is a subtype of type2.
def is_supertype(type1, type2): (source)
Check if type2 is a supertype of type1.
def object_isinstance(node, class_or_seq, context=None): (source)
Check if a node 'isinstance' any node in class_or_seq
Parameters
nodeA given node
class​_or​_seqUnion[nodes.NodeNG, Sequence[nodes.NodeNG]]
contextUndocumented
Returns
boolUndocumented
Raises
AstroidTypeErrorif the given classes_or_seq are not types
def object_issubclass(node, class_or_seq, context=None): (source)
Check if a type is a subclass of any node in class_or_seq
Parameters
nodeA given node
class​_or​_seqUnion[Nodes.NodeNG, Sequence[nodes.NodeNG]]
contextUndocumented
Returns
boolUndocumented
Raises
AstroidTypeErrorif the given classes_or_seq are not types
AstroidErrorif the type of the given node cannot be inferred or its type's mro doesn't work
def object_len(node, context=None): (source)
Infer length of given node object
Parameters
nodeNode to infer length of
contextUndocumented
​Union[nodes​.​Class​Def, nodes​.​Instance] node
Returns
Integer length of nodeUndocumented
Raises
AstroidTypeErrorIf an invalid node is returned from __len__ method or no __len__ method exists
InferenceErrorIf 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
def object_type(node, context=None): (source)

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.

def safe_infer(node, context=None): (source)

Return the inferred value for the given node.

Return None if inference failed or if there is some ambiguity (more than one node has been inferred).

def _build_proxy_class(cls_name, builtins): (source)

Undocumented

def _function_type(function, builtins): (source)

Undocumented

def _object_type(node, context=None): (source)

Undocumented

def _object_type_is_subclass(obj_type, class_or_seq, context=None): (source)

Undocumented

def _type_check(type1, type2): (source)

Undocumented