def visit_import_from(self, node: ImportFrom) -> None: if node.assignments: node.assignments = [] else: if self.names: # Reset entries in the symbol table. This is necessary since # otherwise the semantic analyzer will think that the import # assigns to an existing name instead of defining a new one. for name, as_name in node.names: imported_name = as_name or name symnode = self.names[imported_name] symnode.kind = UNBOUND_IMPORTED symnode.node = None
def visit_import_from(self, node: ImportFrom) -> None: if node.assignments: node.assignments = [] else: # If the node is unreachable, don't reset entries: they point to something else! if node.is_unreachable: return if self.names: # Reset entries in the symbol table. This is necessary since # otherwise the semantic analyzer will think that the import # assigns to an existing name instead of defining a new one. for name, as_name in node.names: imported_name = as_name or name # This assert is safe since we check for self.names above. assert self.file_node is not None sym = create_indirect_imported_name( self.file_node, node.id, node.relative, name) if sym: self.names[imported_name] = sym
def visit_import_from(self, node: ImportFrom) -> None: # Imports can include both overriding symbols and fresh ones, # and we need to clear both. node.assignments = [] # If the node is unreachable, don't reset entries: they point to something else! if node.is_unreachable: return if self.names: # Reset entries in the symbol table. This is necessary since # otherwise the semantic analyzer will think that the import # assigns to an existing name instead of defining a new one. for name, as_name in node.names: imported_name = as_name or name # This assert is safe since we check for self.names above. assert self.file_node is not None sym = create_indirect_imported_name(self.file_node, node.id, node.relative, name) if sym: self.names[imported_name] = sym
def visit_import_from(self, node: ImportFrom) -> None: node.assignments = []