Tweak how ast.pyi imports typing (#2668)

When we import typeshed internally at Dropbox, somehow the fact that
these files are all stubs gets lost (it's a long story...).  This
causes errors like this:

  .../stdlib/2/ast.pyi:6: error: Name 'typing' already defined (by an import)

The quickest way around this is to rename the import to _typing.
This commit is contained in:
Guido van Rossum
2018-12-04 08:25:23 -08:00
committed by Sebastian Rittau
parent 3e4737c683
commit e08a5ac367
2 changed files with 11 additions and 5 deletions

View File

@@ -1,6 +1,9 @@
# Python 2.7 ast
import typing
# Rename typing to _typing, as not to conflict with typing imported
# from _ast below when loaded in an unorthodox way by the Dropbox
# internal Bazel integration.
import typing as _typing
from typing import Any, Iterator, Optional, Union
from _ast import *
@@ -17,7 +20,7 @@ def fix_missing_locations(node: AST) -> AST: ...
def get_docstring(node: AST, clean: bool = ...) -> str: ...
def increment_lineno(node: AST, n: int = ...) -> AST: ...
def iter_child_nodes(node: AST) -> Iterator[AST]: ...
def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ...
def iter_fields(node: AST) -> Iterator[_typing.Tuple[str, Any]]: ...
def literal_eval(node_or_string: Union[str, unicode, AST]) -> Any: ...
def walk(node: AST) -> Iterator[AST]: ...