def visit_call(self, node: nodes.Call) -> None: """Visit a Call node.""" self.check_deprecated_class_in_call(node) for inferred in utils.infer_all(node.func): if inferred is astroid.Uninferable: continue if inferred.root().name in OPEN_MODULE: open_func_name: str | None = None if isinstance(node.func, nodes.Name): open_func_name = node.func.name if isinstance(node.func, nodes.Attribute): open_func_name = node.func.attrname if open_func_name in OPEN_FILES_FUNCS: self._check_open_call(node, inferred.root().name, open_func_name) elif inferred.root().name == UNITTEST_CASE: self._check_redundant_assert(node, inferred) elif isinstance(inferred, nodes.ClassDef): if inferred.qname() == THREADING_THREAD: self._check_bad_thread_instantiation(node) elif inferred.qname() == SUBPROCESS_POPEN: self._check_for_preexec_fn_in_popen(node) elif isinstance(inferred, nodes.FunctionDef): name = inferred.qname() if name == COPY_COPY: self._check_shallow_copy_environ(node) elif name in ENV_GETTERS: self._check_env_function(node, inferred) elif name == SUBPROCESS_RUN: self._check_for_check_kw_in_run(node) elif name in DEBUG_BREAKPOINTS: self.add_message("forgotten-debug-statement", node=node) self.check_deprecated_method(node, inferred)
def is_logger_class(): for inferred in infer_all(node.func): if isinstance(inferred, astroid.BoundMethod): parent = inferred._proxied.parent if isinstance(parent, nodes.ClassDef) and ( parent.qname() == "logging.Logger" or any(ancestor.qname() == "logging.Logger" for ancestor in parent.ancestors())): return True, inferred._proxied.name return False, None
def visit_call(self, node: nodes.Call) -> None: """Called when a :class:`nodes.Call` node is visited.""" self.check_deprecated_class_in_call(node) for inferred in infer_all(node.func): # Calling entry point for deprecation check logic. self.check_deprecated_method(node, inferred)
def visit_call(self, node: nodes.Call) -> None: """Check instantiating abstract class with abc.ABCMeta as metaclass. """ for inferred in infer_all(node.func): self._check_inferred_class_is_abstract(inferred, node)