def is_super(node: astroid.node_classes.NodeNG) -> bool: """return True if the node is referencing the "super" builtin function """ if getattr(node, "name", None) == "super" and node.root().name == BUILTINS_NAME: return True return False
def is_postponed_evaluation_enabled(node: astroid.node_classes.NodeNG) -> bool: """Check if the postponed evaluation of annotations is enabled""" if PY310_PLUS: return True module = node.root() return "annotations" in module.future_imports
def is_postponed_evaluation_enabled(node: astroid.node_classes.NodeNG) -> bool: """Check if the postponed evaluation of annotations is enabled""" name = "annotations" module = node.root() stmt = module.locals.get(name) return (stmt and isinstance(stmt[0], astroid.ImportFrom) and stmt[0].modname == "__future__")
def looks_like_numpy_member( member_name: str, node: astroid.node_classes.NodeNG ) -> bool: """ Returns True if the node is a member of numpy whose name is member_name. :param member_name: name of the member :param node: node to test :return: True if the node is a member of numpy """ if ( isinstance(node, astroid.Attribute) and node.attrname == member_name and isinstance(node.expr, astroid.Name) and _is_a_numpy_module(node.expr) ): return True if ( isinstance(node, astroid.Name) and node.name == member_name and node.root().name.startswith("numpy") ): return True return False
def is_super(node: astroid.node_classes.NodeNG) -> bool: """return True if the node is referencing the "super" builtin function """ if getattr(node, 'name', None) == 'super' and \ node.root().name == BUILTINS_NAME: return True return False
def is_postponed_evaluation_enabled(node: astroid.node_classes.NodeNG) -> bool: """Check if the postponed evaluation of annotations is enabled""" name = "annotations" module = node.root() stmt = module.locals.get(name) return ( stmt and isinstance(stmt[0], astroid.ImportFrom) and stmt[0].modname == "__future__" )
def inherit_from_std_ex(node: astroid.node_classes.NodeNG) -> bool: """ Return true if the given class node is subclass of exceptions.Exception. """ if (node.name in ("Exception", "BaseException") and node.root().name == EXCEPTIONS_MODULE): return True if not hasattr(node, "ancestors"): return False return any( inherit_from_std_ex(parent) for parent in node.ancestors(recurs=True))
def inherit_from_std_ex(node: astroid.node_classes.NodeNG) -> bool: """ Return true if the given class node is subclass of exceptions.Exception. """ if node.name in ('Exception', 'BaseException') \ and node.root().name == EXCEPTIONS_MODULE: return True if not hasattr(node, 'ancestors'): return False return any(inherit_from_std_ex(parent) for parent in node.ancestors(recurs=True))
def is_builtin_object(node: astroid.node_classes.NodeNG) -> bool: """Returns True if the given node is an object from the __builtin__ module.""" return node and node.root().name == BUILTINS_NAME