From 3f9fafbbb76cf3251d421616a7ec5b1bf4f40383 Mon Sep 17 00:00:00 2001 From: Svyatoslav Ilinskiy Date: Thu, 3 Aug 2017 15:57:20 -0700 Subject: [PATCH] Re-export code from _ast into ast. (#1515) After mypy [started hiding](https://github.com/python/mypy/pull/3706) imported names in stubs unless `from ... import ...` is used, we found an error with stubs of ast module. It looks like ast module should re-export everything in `_ast` and according to PEP 484, it can do that by doing `from _ast import *`, so this is what this PR does. --- stdlib/2/ast.pyi | 14 +------------- stdlib/3/ast.pyi | 15 +-------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/stdlib/2/ast.pyi b/stdlib/2/ast.pyi index d22a6f8b6..9b48cf196 100644 --- a/stdlib/2/ast.pyi +++ b/stdlib/2/ast.pyi @@ -3,19 +3,7 @@ import typing from typing import Any, Iterator, Union -from _ast import ( - Add, alias, And, arguments, Assert, Assign, AST, Attribute, AugAssign, - AugLoad, AugStore, BinOp, BitAnd, BitOr, BitXor, BoolOp, boolop, Break, - Call, ClassDef, cmpop, Compare, comprehension, Continue, Del, Delete, Dict, - DictComp, Div, Ellipsis, Eq, ExceptHandler, Exec, Expr, expr, Expression, - expr_context, ExtSlice, FloorDiv, For, FunctionDef, GeneratorExp, Global, - Gt, GtE, If, IfExp, Import, ImportFrom, In, Index, Interactive, Invert, Is, - IsNot, keyword, Lambda, List, ListComp, Load, LShift, Lt, LtE, Mod, mod, - Module, Mult, Name, Not, NotEq, NotIn, Num, operator, Or, Param, Pass, Pow, - Print, Raise, Repr, Return, RShift, Set, SetComp, Slice, slice, stmt, - Store, Str, Sub, Subscript, Suite, TryExcept, TryFinally, Tuple, UAdd, - UnaryOp, unaryop, USub, While, With, Yield -) +from _ast import * __version__ = ... # type: str PyCF_ONLY_AST = ... # type: int diff --git a/stdlib/3/ast.pyi b/stdlib/3/ast.pyi index 534567650..241f874f1 100644 --- a/stdlib/3/ast.pyi +++ b/stdlib/3/ast.pyi @@ -3,20 +3,7 @@ import typing from typing import Any, Union, Iterator -from _ast import ( - Add, alias, And, arg, arguments, Assert, Assign, AST, AsyncFor, - AsyncFunctionDef, AsyncWith, Attribute, AugAssign, AugLoad, AugStore, - Await, BinOp, BitAnd, BitOr, BitXor, BoolOp, boolop, Break, Bytes, Call, - ClassDef, cmpop, Compare, comprehension, Continue, Del, Delete, Dict, - DictComp, Div, Ellipsis, Eq, ExceptHandler, Expr, expr, Expression, - expr_context, ExtSlice, FloorDiv, For, FunctionDef, GeneratorExp, Global, - Gt, GtE, If, IfExp, Import, ImportFrom, In, Index, Interactive, Invert, Is, - IsNot, keyword, Lambda, List, ListComp, Load, LShift, Lt, LtE, MatMult, - Mod, mod, Module, Mult, Name, NameConstant, Nonlocal, Not, NotEq, NotIn, - Num, operator, Or, Param, Pass, Pow, Raise, Return, RShift, Set, SetComp, - Slice, slice, Starred, stmt, Store, Str, Sub, Subscript, Suite, Try, Tuple, - UAdd, UnaryOp, unaryop, USub, While, With, withitem, Yield, YieldFrom -) +from _ast import * class NodeVisitor(): def visit(self, node: AST) -> Any: ...