def visit_import_all(self, node: ImportAll) -> None: # Imports can include both overriding symbols and fresh ones, # and we need to clear both. node.assignments = [] # If the node is unreachable, we don't want to reset entries from a reachable import. if node.is_unreachable: return # Reset entries in the symbol table that were added through the statement. # (The description in visit_import is relevant here as well.) if self.names: for name in node.imported_names: if name in self.names: del self.names[name] node.imported_names = []
def visit_ImportFrom(self, n): if len(n.names) == 1 and n.names[0].name == '*': i = ImportAll(n.module, n.level) else: i = ImportFrom(n.module if n.module is not None else '', n.level, [(a.name, a.asname) for a in n.names]) self.imports.append(i) return i
def visit_import_all(self, node: ImportAll) -> None: # If the node is unreachable, we don't want to reset entries from a reachable import. if node.is_unreachable: return # Reset entries in the symbol table that were added through the statement. # (The description in visit_import is relevant here as well.) if self.names: for name in node.imported_names: del self.names[name] node.imported_names = []
def visit_ImportFrom(self, n: ast35.ImportFrom) -> Node: i = None # type: ImportBase if len(n.names) == 1 and n.names[0].name == '*': i = ImportAll(n.module, n.level) else: i = ImportFrom(self.translate_module_id(n.module) if n.module is not None else '', n.level, [(a.name, a.asname) for a in n.names]) self.imports.append(i) return i
def visit_ImportFrom(self, n: ast27.ImportFrom) -> ImportBase: assert n.level is not None if len(n.names) == 1 and n.names[0].name == '*': mod = n.module if n.module is not None else '' i = ImportAll(mod, n.level) # type: ImportBase else: i = ImportFrom(self.translate_module_id(n.module) if n.module is not None else '', n.level, [(a.name, a.asname) for a in n.names]) self.imports.append(i) return i
def visit_ImportFrom(self, n: ast27.ImportFrom) -> ImportBase: assert n.level is not None if len(n.names) == 1 and n.names[0].name == '*': mod = n.module if n.module is not None else '' i = ImportAll(mod, n.level) # type: ImportBase else: module_id = self.translate_module_id(n.module) if n.module is not None else '' i = ImportFrom(module_id, n.level, [(a.name, a.asname) for a in n.names]) # See comments in the constructor for more information about this field. if module_id == '__future__' and any(a.name == 'unicode_literals' for a in n.names): self.unicode_literals = True self.imports.append(i) return self.set_line(i, n)
def visit_import_all(self, node: ImportAll) -> Node: return ImportAll(node.id, node.relative)
def visit_import_all(self, node: ImportAll) -> None: node.assignments = [] node.imported_names = []
def visit_import_all(self, node: ImportAll) -> None: node.is_top_level = self.sem.is_module_scope()
def visit_import_all(self, node: ImportAll) -> None: node.is_mypy_only = True
def visit_import_all(self, node: ImportAll) -> None: node.is_unreachable = True
def visit_import_all(self, node: ImportAll) -> None: node.is_top_level = self.is_global_scope super().visit_import_all(node)