示例#1
0
文件: aststrip.py 项目: surannya/mypy
 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
示例#2
0
 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
示例#3
0
 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
示例#4
0
    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
示例#5
0
 def visit_import_from(self, node: ImportFrom) -> None:
     node.assignments = []
示例#6
0
 def visit_import_from(self, node: ImportFrom) -> None:
     node.assignments = []