def visit_ImportFrom(self, node): if node.module and node.module.split(".")[0] == self.name: self.result = True # Based on ast.NodeVisitor.visit