diff --git a/stdlib/2.7/_ast.pyi b/stdlib/2.7/_ast.pyi index bd8d259e5..26f9ce1fc 100644 --- a/stdlib/2.7/_ast.pyi +++ b/stdlib/2.7/_ast.pyi @@ -1,516 +1,328 @@ -from typing import Any -from typing import Tuple as TypingTuple +import typing +from typing import Optional, Union -__version__ = ... # type: int +__version__ = ... # type: str PyCF_ONLY_AST = ... # type: int -class AST(object): - _attributes = ... # type: TypingTuple[str] - _fields = ... # type: TypingTuple[str] - def __init__(self, *args, **kwargs) -> None: pass +identifier = str -class alias(AST): - pass - -class arguments(AST): - pass - -class boolop(AST): - pass - -class cmpop(AST): - pass - -class comprehension(AST): - pass - -class excepthandler(AST): - pass - -class expr(AST): - pass - -class expr_context(AST): - pass - -class keyword(AST): - pass +class AST: + _attributes = ... # type: typing.Tuple[str, ...] + _fields = ... # type: typing.Tuple[str, ...] + def __init__(self, *args, **kwargs) -> None: ... class mod(AST): - pass - -class operator(AST): - pass - -class slice(AST): - pass - -class stmt(AST): - pass - -class unaryop(AST): - pass - - -class Add(operator): - def __init__(self) -> None: - pass - -class And(boolop): - def __init__(self) -> None: - pass - -class Assert(stmt): - test = ... # type: Any - msg = ... # type: Any - def __init__(self, test = ..., msg = ...) -> None: - pass - -class Assign(stmt): - targets = ... # type: Any - value = ... # type: Any - def __init__(self, targets = ..., value = ...) -> None: - pass - -class Attribute(expr): - value = ... # type: Any - attr = ... # type: Any - ctx = ... # type: Any - def __init__(self, value = ..., attr = ..., ctx = ...) -> None: - pass - -class AugAssign(stmt): - target = ... # type: Any - op = ... # type: Any - value = ... # type: Any - def __init__(self, target = ..., op = ..., value = ...) -> None: - pass - -class AugLoad(expr_context): - def __init__(self) -> None: - pass - -class AugStore(expr_context): - def __init__(self) -> None: - pass - -class BinOp(expr): - left = ... # type: Any - op = ... # type: Any - right = ... # type: Any - def __init__(self, left = ..., op = ..., right = ...) -> None: - pass - -class BitAnd(operator): - def __init__(self) -> None: - pass - -class BitOr(operator): - def __init__(self) -> None: - pass - -class BitXor(operator): - def __init__(self) -> None: - pass - -class BoolOp(expr): - op = ... # type: Any - values = ... # type: Any - def __init__(self, op = ..., values = ...) -> None: - pass - -class Break(stmt): - def __init__(self) -> None: - pass - -class Call(expr): - func = ... # type: Any - args = ... # type: Any - keywords = ... # type: Any - starargs = ... # type: Any - kwargs = ... # type: Any - def __init__(self, func = ..., args = ..., keywords = ..., starargs = ..., kwargs = ...) -> None: - pass - -class ClassDef(stmt): - name = ... # type: Any - bases = ... # type: Any - body = ... # type: Any - decorator_list = ... # type: Any - def __init__(self, name = ..., bases = ..., body = ..., decorator_list = ...) -> None: - pass - -class Compare(expr): - left = ... # type: Any - ops = ... # type: Any - comparators = ... # type: Any - def __init__(self, left = ..., ops = ..., comparators = ...) -> None: - pass - -class Continue(stmt): - def __init__(self) -> None: - pass - -class Del(expr_context): - def __init__(self) -> None: - pass - -class Delete(stmt): - targets = ... # type: Any - def __init__(self, targets = ...) -> None: - pass - -class Dict(expr): - keys = ... # type: Any - values = ... # type: Any - def __init__(self, keys = ..., values = ...) -> None: - pass - -class DictComp(expr): - key = ... # type: Any - value = ... # type: Any - generators = ... # type: Any - def __init__(self, key = ..., value = ..., generators = ...) -> None: - pass - -class Div(operator): - def __init__(self) -> None: - pass - -class Ellipsis(slice): - def __init__(self) -> None: - pass - -class Eq(cmpop): - def __init__(self) -> None: - pass - -class ExceptHandler(excepthandler): - type = ... # type: Any - name = ... # type: Any - body = ... # type: Any - def __init__(self, type = ..., name = ..., body = ...) -> None: - pass - -class Exec(stmt): - body = ... # type: Any - globals = ... # type: Any - locals = ... # type: Any - def __init__(self, body = ..., globals = ..., locals = ...) -> None: - pass - -class Expr(stmt): - value = ... # type: Any - def __init__(self, value = ...) -> None: - pass - -class Expression(mod): - body = ... # type: Any - def __init__(self, body = ...) -> None: - pass - -class ExtSlice(slice): - dims = ... # type: Any - def __init__(self, dims = ...) -> None: - pass - -class FloorDiv(operator): - def __init__(self) -> None: - pass - -class For(stmt): - target = ... # type: Any - iter = ... # type: Any - body = ... # type: Any - orelse = ... # type: Any - def __init__(self, target = ..., iter = ..., body = ..., orelse = ...) -> None: - pass - -class FunctionDef(stmt): - name = ... # type: Any - args = ... # type: Any - body = ... # type: Any - decorator_list = ... # type: Any - def __init__(self, name = ..., args = ..., body = ..., decorator_list = ...) -> None: - pass - -class GeneratorExp(expr): - elt = ... # type: Any - generators = ... # type: Any - def __init__(self, elt = ..., generators = ...) -> None: - pass - -class Global(stmt): - names = ... # type: Any - def __init__(self, names = ...) -> None: - pass - -class Gt(cmpop): - def __init__(self) -> None: - pass - -class GtE(cmpop): - def __init__(self) -> None: - pass - -class If(stmt): - test = ... # type: Any - body = ... # type: Any - orelse = ... # type: Any - def __init__(self, test = ..., body = ..., orelse = ...) -> None: - pass - -class IfExp(expr): - test = ... # type: Any - body = ... # type: Any - orelse = ... # type: Any - def __init__(self, test = ..., body = ..., orelse = ...) -> None: - pass - -class Import(stmt): - names = ... # type: Any - def __init__(self, names = ...) -> None: - pass - -class ImportFrom(stmt): - module = ... # type: Any - names = ... # type: Any - level = ... # type: Any - def __init__(self, module = ..., names = ..., level = ...) -> None: - pass - -class In(cmpop): - def __init__(self) -> None: - pass - -class Index(slice): - value = ... # type: Any - def __init__(self, value = ...) -> None: - pass - -class Interactive(mod): - body = ... # type: Any - def __init__(self, body = ...) -> None: - pass - -class Invert(unaryop): - def __init__(self) -> None: - pass - -class Is(cmpop): - def __init__(self) -> None: - pass - -class IsNot(cmpop): - def __init__(self) -> None: - pass - -class LShift(operator): - def __init__(self) -> None: - pass - -class Lambda(expr): - args = ... # type: Any - body = ... # type: Any - def __init__(self, args = ..., body = ...) -> None: - pass - -class List(expr): - elts = ... # type: Any - ctx = ... # type: Any - def __init__(self, elts = ..., ctx = ...) -> None: - pass - -class ListComp(expr): - elt = ... # type: Any - generators = ... # type: Any - def __init__(self, elt = ..., generators = ...) -> None: - pass - -class Load(expr_context): - def __init__(self) -> None: - pass - -class Lt(cmpop): - def __init__(self) -> None: - pass - -class LtE(cmpop): - def __init__(self) -> None: - pass - -class Mod(operator): - def __init__(self) -> None: - pass + ... class Module(mod): - body = ... # type: Any - def __init__(self, body = ...) -> None: - pass + body = ... # type: typing.List[stmt] -class Mult(operator): - def __init__(self) -> None: - pass +class Interactive(mod): + body = ... # type: typing.List[stmt] -class Name(expr): - id = ... # type: Any - ctx = ... # type: Any - def __init__(self, id = ..., ctx = ...) -> None: - pass - -class Not(unaryop): - def __init__(self) -> None: - pass - -class NotEq(cmpop): - def __init__(self) -> None: - pass - -class NotIn(cmpop): - def __init__(self) -> None: - pass - -class Num(expr): - n = ... # type: Any - def __init__(self, n = ...) -> None: - pass - -class Or(boolop): - def __init__(self) -> None: - pass - -class Param(expr_context): - def __init__(self) -> None: - pass - -class Pass(stmt): - def __init__(self) -> None: - pass - -class Pow(operator): - def __init__(self) -> None: - pass - -class Print(stmt): - dest = ... # type: Any - values = ... # type: Any - nl = ... # type: Any - def __init__(self, dest = ..., values = ..., nl = ...) -> None: - pass - -class RShift(operator): - def __init__(self) -> None: - pass - -class Raise(stmt): - type = ... # type: Any - inst = ... # type: Any - tback = ... # type: Any - def __init__(self, type = ..., inst = ..., tback = ...) -> None: - pass - -class Repr(expr): - value = ... # type: Any - def __init__(self, value = ...) -> None: - pass - -class Return(stmt): - value = ... # type: Any - def __init__(self, value = ...) -> None: - pass - -class Set(expr): - elts = ... # type: Any - def __init__(self, elts = ...) -> None: - pass - -class SetComp(expr): - elt = ... # type: Any - generators = ... # type: Any - def __init__(self, elt = ..., generators = ...) -> None: - pass - -class Slice(slice): - lower = ... # type: Any - upper = ... # type: Any - step = ... # type: Any - def __init__(self, lower = ..., upper = ..., step = ...) -> None: - pass - -class Store(expr_context): - def __init__(self) -> None: - pass - -class Str(expr): - s = ... # type: Any - def __init__(self, s = ...) -> None: - pass - -class Sub(operator): - def __init__(self) -> None: - pass - -class Subscript(expr): - value = ... # type: Any - slice = ... # type: Any - ctx = ... # type: Any - def __init__(self, value = ..., slice = ..., ctx = ...) -> None: - pass +class Expression(mod): + body = ... # type: expr class Suite(mod): - body = ... # type: Any - def __init__(self, body = ...) -> None: - pass + body = ... # type: typing.List[stmt] -class TryExcept(stmt): - body = ... # type: Any - handlers = ... # type: Any - orelse = ... # type: Any - def __init__(self, body = ..., handlers = ..., orelse = ...) -> None: - pass -class TryFinally(stmt): - body = ... # type: Any - finalbody = ... # type: Any - def __init__(self, body = ..., finalbody = ...) -> None: - pass +class stmt(AST): + lineno = ... # type: int + col_offset = ... # type: int -class Tuple(expr): - elts = ... # type: Any - ctx = ... # type: Any - def __init__(self, elts = ..., ctx = ...) -> None: - pass +class FunctionDef(stmt): + name = ... # type: identifier + args = ... # type: arguments + body = ... # type: typing.List[stmt] + decorator_list = ... # type: typing.List[expr] -class UAdd(unaryop): - def __init__(self) -> None: - pass +class ClassDef(stmt): + name = ... # type: identifier + bases = ... # type: typing.List[expr] + body = ... # type: typing.List[stmt] + decorator_list = ... # type: typing.List[expr] -class USub(unaryop): - def __init__(self) -> None: - pass +class Return(stmt): + value = ... # type: Optional[expr] -class UnaryOp(expr): - op = ... # type: Any - operand = ... # type: Any - def __init__(self, op = ..., operand = ...) -> None: - pass +class Delete(stmt): + targets = ... # type: typing.List[expr] + +class Assign(stmt): + targets = ... # type: typing.List[expr] + value = ... # type: expr + +class AugAssign(stmt): + target = ... # type: expr + op = ... # type: operator + value = ... # type: expr + +class Print(stmt): + dest = ... # type: Optional[expr] + values = ... # type: typing.List[expr] + nl = ... # type: bool + +class For(stmt): + target = ... # type: expr + iter = ... # type: expr + body = ... # type: typing.List[stmt] + orelse = ... # type: typing.List[stmt] class While(stmt): - test = ... # type: Any - body = ... # type: Any - orelse = ... # type: Any - def __init__(self, test = ..., body = ..., orelse = ...) -> None: - pass + test = ... # type: expr + body = ... # type: typing.List[stmt] + orelse = ... # type: typing.List[stmt] + +class If(stmt): + test = ... # type: expr + body = ... # type: typing.List[stmt] + orelse = ... # type: typing.List[stmt] class With(stmt): - context_expr = ... # type: Any - optional_vars = ... # type: Any - body = ... # type: Any - def __init__(self, context_expr = ..., optional_vars = ..., body = ...) -> None: - pass + context_expr = ... # type: expr + optional_vars = ... # type: Optional[expr] + body = ... # type: typing.List[stmt] + +class Raise(stmt): + type = ... # type: Optional[expr] + inst = ... # type: Optional[expr] + tback = ... # type: Optional[expr] + +class TryExcept(stmt): + body = ... # type: typing.List[stmt] + handlers = ... # type: typing.List[ExceptHandler] + orelse = ... # type: typing.List[stmt] + +class TryFinally(stmt): + body = ... # type: typing.List[stmt] + finalbody = ... # type: typing.List[stmt] + +class Assert(stmt): + test = ... # type: expr + msg = ... # type: Optional[expr] + +class Import(stmt): + names = ... # type: typing.List[alias] + +class ImportFrom(stmt): + module = ... # type: Optional[identifier] + names = ... # type: typing.List[alias] + level = ... # type: Optional[int] + +class Exec(stmt): + body = ... # type: expr + globals = ... # type: Optional[expr] + locals = ... # type: Optional[expr] + +class Global(stmt): + names = ... # type: typing.List[identifier] + +class Expr(stmt): + value = ... # type: expr + +class Pass(stmt): ... +class Break(stmt): ... +class Continue(stmt): ... + + +class slice(AST): + ... + +_slice = slice # this lets us type the variable named 'slice' below + +class Slice(slice): + lower = ... # type: Optional[expr] + upper = ... # type: Optional[expr] + step = ... # type: Optional[expr] + +class ExtSlice(slice): + dims = ... # type: typing.List[slice] + +class Index(slice): + value = ... # type: expr + +class Ellipsis(slice): ... + + +class expr(AST): + lineno = ... # type: int + col_offset = ... # type: int + +class BoolOp(expr): + op = ... # type: boolop + values = ... # type: typing.List[expr] + +class BinOp(expr): + left = ... # type: expr + op = ... # type: operator + right = ... # type: expr + +class UnaryOp(expr): + op = ... # type: unaryop + operand = ... # type: expr + +class Lambda(expr): + args = ... # type: arguments + body = ... # type: expr + +class IfExp(expr): + test = ... # type: expr + body = ... # type: expr + orelse = ... # type: expr + +class Dict(expr): + keys = ... # type: typing.List[expr] + values = ... # type: typing.List[expr] + +class Set(expr): + elts = ... # type: typing.List[expr] + +class ListComp(expr): + elt = ... # type: expr + generators = ... # type: typing.List[comprehension] + +class SetComp(expr): + elt = ... # type: expr + generators = ... # type: typing.List[comprehension] + +class DictComp(expr): + key = ... # type: expr + value = ... # type: expr + generators = ... # type: typing.List[comprehension] + +class GeneratorExp(expr): + elt = ... # type: expr + generators = ... # type: typing.List[comprehension] class Yield(expr): - value = ... # type: Any - def __init__(self, value = ...) -> None: - pass + value = ... # type: Optional[expr] + +class Compare(expr): + left = ... # type: expr + ops = ... # type: typing.List[cmpop] + comparators = ... # type: typing.List[expr] + +class Call(expr): + func = ... # type: expr + args = ... # type: typing.List[expr] + keywords = ... # type: typing.List[keyword] + starargs = ... # type: Optional[expr] + kwargs = ... # type: Optional[expr] + +class Repr(expr): + value = ... # type: expr + +class Num(expr): + n = ... # type: Union[int, float] + +class Str(expr): + s = ... # type: str + +class Attribute(expr): + value = ... # type: expr + attr = ... # type: identifier + ctx = ... # type: expr_context + +class Subscript(expr): + value = ... # type: expr + slice = ... # type: _slice + ctx = ... # type: expr_context + +class Name(expr): + id = ... # type: identifier + ctx = ... # type: expr_context + +class List(expr): + elts = ... # type: typing.List[expr] + ctx = ... # type: expr_context + +class Tuple(expr): + elts = ... # type: typing.List[expr] + ctx = ... # type: expr_context + + +class expr_context(AST): + ... + +class AugLoad(expr_context): ... +class AugStore(expr_context): ... +class Del(expr_context): ... +class Load(expr_context): ... +class Param(expr_context): ... +class Store(expr_context): ... + + +class boolop(AST): + ... + +class And(boolop): ... +class Or(boolop): ... + +class operator(AST): + ... + +class Add(operator): ... +class BitAnd(operator): ... +class BitOr(operator): ... +class BitXor(operator): ... +class Div(operator): ... +class FloorDiv(operator): ... +class LShift(operator): ... +class Mod(operator): ... +class Mult(operator): ... +class Pow(operator): ... +class RShift(operator): ... +class Sub(operator): ... + +class unaryop(AST): + ... + +class Invert(unaryop): ... +class Not(unaryop): ... +class UAdd(unaryop): ... +class USub(unaryop): ... + +class cmpop(AST): + ... + +class Eq(cmpop): ... +class Gt(cmpop): ... +class GtE(cmpop): ... +class In(cmpop): ... +class Is(cmpop): ... +class IsNot(cmpop): ... +class Lt(cmpop): ... +class LtE(cmpop): ... +class NotEq(cmpop): ... +class NotIn(cmpop): ... + + +class comprehension(AST): + target = ... # type: expr + iter = ... # type: expr + ifs = ... # type: typing.List[expr] + + +class ExceptHandler(AST): + type = ... # type: Optional[expr] + name = ... # type: Optional[expr] + body = ... # type: typing.List[stmt] + lineno = ... # type: int + col_offset = ... # type: int + + +class arguments(AST): + args = ... # type: typing.List[expr] + vararg = ... # type: Optional[identifier] + kwarg = ... # type: Optional[identifier] + defaults = ... # type: typing.List[expr] + +class keyword(AST): + arg = ... # type: identifier + value = ... # type: expr + +class alias(AST): + name = ... # type: identifier + asname = ... # type: Optional[identifier] diff --git a/stdlib/2.7/ast.pyi b/stdlib/2.7/ast.pyi index dbaf6afe6..1864d315c 100644 --- a/stdlib/2.7/ast.pyi +++ b/stdlib/2.7/ast.pyi @@ -1,40 +1,45 @@ -# Automatically generated by pytype. May contain errors. +# Python 2.7 ast -from typing import Any, Tuple, Generator +import typing +from typing import Any, Tuple, Iterator, Union from _ast import ( - AST, alias, arguments, boolop, cmpop, comprehension, excepthandler, - expr, expr_context, keyword, mod, operator, slice, stmt, unaryop, Add, - And, Assert, Assign, Attribute, AugAssign, AugLoad, AugStore, BinOp, - BitAnd, BitOr, BitXor, BoolOp, Break, Call, ClassDef, Compare, Continue, - Del, Delete, Dict, DictComp, Div, Ellipsis, Eq, ExceptHandler, Exec, - Expr, Expression, ExtSlice, FloorDiv, For, FunctionDef, GeneratorExp, - Global, Gt, GtE, If, IfExp, Import, ImportFrom, In, Index, Interactive, - Invert, Is, IsNot, LShift, Lambda, List, ListComp, Load, Lt, LtE, Mod, - Module, Mult, Name, Not, NotEq, NotIn, Num, Or, Param, Pass, Pow, Print, - RShift, Raise, Repr, Return, Set, SetComp, Slice, Store, Str, Sub, - Subscript, Suite, TryExcept, TryFinally, Tuple, UAdd, USub, UnaryOp, - While, With, Yield) + 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 +) -__version__ = ... # type: int +__version__ = ... # type: str PyCF_ONLY_AST = ... # type: int -def copy_location(new_node, old_node) -> Any: ... -def dump(node, *args, **kwargs) -> str: ... -def fix_missing_locations(node) -> Any: ... -def get_docstring(node, *args, **kwargs) -> Any: ... -def increment_lineno(node, *args, **kwargs) -> Any: ... -def iter_child_nodes(node) -> Generator[Any, Any, Any]: ... -def iter_fields(node) -> Any: ... # TODO: Generator[Tuple[Any, ...]]: ... -def literal_eval(node_or_string) -> Any: ... -def parse(source, filename = ..., mode = ..., *args, **kwargs) -> AST: ... -def walk(node) -> Any: ... # TODO: Generator[Any]: ... -class NodeVisitor(object): +def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ... +def copy_location(new_node: AST, old_node: AST) -> AST: ... +def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... +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 literal_eval(node_or_string: Union[str, AST]) -> Any: ... +def walk(node: AST) -> Iterator[AST]: ... + +class NodeVisitor(): __doc__ = ... # type: str - def generic_visit(self, node) -> None: ... - def visit(self, node) -> Any: ... + def visit(self, node: AST) -> Any: ... + def generic_visit(self, node: AST) -> None: ... class NodeTransformer(NodeVisitor): __doc__ = ... # type: str - def generic_visit(self, node) -> Any: ... + def generic_visit(self, node: AST) -> None: ... + + + diff --git a/stdlib/3/_ast.pyi b/stdlib/3/_ast.pyi new file mode 100644 index 000000000..23bf799a4 --- /dev/null +++ b/stdlib/3/_ast.pyi @@ -0,0 +1,358 @@ +# Python 3.5 _ast +import typing +from typing import Any, Optional, Union + +PyCF_ONLY_AST = ... # type: int + +identifier = str + +class AST: + _attributes = ... # type: typing.Tuple[str, ...] + _fields = ... # type: typing.Tuple[str, ...] + def __init__(self, *args, **kwargs) -> None: ... + +class mod(AST): + ... + +class Module(mod): + body = ... # type: typing.List[stmt] + +class Interactive(mod): + body = ... # type: typing.List[stmt] + +class Expression(mod): + body = ... # type: expr + +class Suite(mod): + body = ... # type: typing.List[stmt] + + +class stmt(AST): + lineno = ... # type: int + col_offset = ... # type: int + +class FunctionDef(stmt): + name = ... # type: identifier + args = ... # type: arguments + body = ... # type: typing.List[stmt] + decorator_list = ... # type: typing.List[expr] + returns = ... # type: Optional[expr] + +class AsyncFunctionDef(stmt): + name = ... # type: identifier + args = ... # type: arguments + body = ... # type: typing.List[stmt] + decorator_list = ... # type: typing.List[expr] + returns = ... # type: Optional[expr] + +class ClassDef(stmt): + name = ... # type: identifier + bases = ... # type: typing.List[expr] + keywords = ... # type: typing.List[keyword] + body = ... # type: typing.List[stmt] + decorator_list = ... # type: typing.List[expr] + +class Return(stmt): + value = ... # type: Optional[expr] + +class Delete(stmt): + targets = ... # type: typing.List[expr] + +class Assign(stmt): + targets = ... # type: typing.List[expr] + value = ... # type: expr + +class AugAssign(stmt): + target = ... # type: expr + op = ... # type: operator + value = ... # type: expr + +class For(stmt): + target = ... # type: expr + iter = ... # type: expr + body = ... # type: typing.List[stmt] + orelse = ... # type: typing.List[stmt] + +class AsyncFor(stmt): + target = ... # type: expr + iter = ... # type: expr + body = ... # type: typing.List[stmt] + orelse = ... # type: typing.List[stmt] + +class While(stmt): + test = ... # type: expr + body = ... # type: typing.List[stmt] + orelse = ... # type: typing.List[stmt] + +class If(stmt): + test = ... # type: expr + body = ... # type: typing.List[stmt] + orelse = ... # type: typing.List[stmt] + +class With(stmt): + items = ... # type: typing.List[withitem] + body = ... # type: typing.List[stmt] + +class AsyncWith(stmt): + items = ... # type: typing.List[withitem] + body = ... # type: typing.List[stmt] + +class Raise(stmt): + exc = ... # type: Optional[expr] + cause = ... # type: Optional[expr] + +class Try(stmt): + body = ... # type: typing.List[stmt] + handlers = ... # type: typing.List[ExceptHandler] + orelse = ... # type: typing.List[stmt] + finalbody = ... # type: typing.List[stmt] + +class Assert(stmt): + test = ... # type: expr + msg = ... # type: Optional[expr] + +class Import(stmt): + names = ... # type: typing.List[alias] + +class ImportFrom(stmt): + module = ... # type: Optional[identifier] + names = ... # type: typing.List[alias] + level = ... # type: Optional[int] + +class Global(stmt): + names = ... # type: typing.List[identifier] + +class Nonlocal(stmt): + names = ... # type: typing.List[identifier] + +class Expr(stmt): + value = ... # type: expr + +class Pass(stmt): ... +class Break(stmt): ... +class Continue(stmt): ... + + +class slice(AST): + ... + +_slice = slice # this lets us type the variable named 'slice' below + +class Slice(slice): + lower = ... # type: Optional[expr] + upper = ... # type: Optional[expr] + step = ... # type: Optional[expr] + +class ExtSlice(slice): + dims = ... # type: typing.List[slice] + +class Index(slice): + value = ... # type: expr + + +class expr(AST): + lineno = ... # type: int + col_offset = ... # type: int + +class BoolOp(expr): + op = ... # type: boolop + values = ... # type: typing.List[expr] + +class BinOp(expr): + left = ... # type: expr + op = ... # type: operator + right = ... # type: expr + +class UnaryOp(expr): + op = ... # type: unaryop + operand = ... # type: expr + +class Lambda(expr): + args = ... # type: arguments + body = ... # type: expr + +class IfExp(expr): + test = ... # type: expr + body = ... # type: expr + orelse = ... # type: expr + +class Dict(expr): + keys = ... # type: typing.List[expr] + values = ... # type: typing.List[expr] + +class Set(expr): + elts = ... # type: typing.List[expr] + +class ListComp(expr): + elt = ... # type: expr + generators = ... # type: typing.List[comprehension] + +class SetComp(expr): + elt = ... # type: expr + generators = ... # type: typing.List[comprehension] + +class DictComp(expr): + key = ... # type: expr + value = ... # type: expr + generators = ... # type: typing.List[comprehension] + +class GeneratorExp(expr): + elt = ... # type: expr + generators = ... # type: typing.List[comprehension] + +class Await(expr): + value = ... # type: expr + +class Yield(expr): + value = ... # type: Optional[expr] + +class YieldFrom(expr): + value = ... # type: expr + +class Compare(expr): + left = ... # type: expr + ops = ... # type: typing.List[cmpop] + comparators = ... # type: typing.List[expr] + +class Call(expr): + func = ... # type: expr + args = ... # type: typing.List[expr] + keywords = ... # type: typing.List[keyword] + +class Num(expr): + n = ... # type: Union[int, float] + +class Str(expr): + s = ... # type: str + +class Bytes(expr): + s = ... # type: bytes + +class NameConstant(expr): + value = ... # type: Any + +class Ellipsis(expr): ... + +class Attribute(expr): + value = ... # type: expr + attr = ... # type: identifier + ctx = ... # type: expr_context + +class Subscript(expr): + value = ... # type: expr + slice = ... # type: _slice + ctx = ... # type: expr_context + +class Starred(expr): + value = ... # type: expr + ctx = ... # type: expr_context + +class Name(expr): + id = ... # type: identifier + ctx = ... # type: expr_context + +class List(expr): + elts = ... # type: typing.List[expr] + ctx = ... # type: expr_context + +class Tuple(expr): + elts = ... # type: typing.List[expr] + ctx = ... # type: expr_context + + +class expr_context(AST): + ... + +class AugLoad(expr_context): ... +class AugStore(expr_context): ... +class Del(expr_context): ... +class Load(expr_context): ... +class Param(expr_context): ... +class Store(expr_context): ... + + +class boolop(AST): + ... + +class And(boolop): ... +class Or(boolop): ... + +class operator(AST): + ... + +class Add(operator): ... +class BitAnd(operator): ... +class BitOr(operator): ... +class BitXor(operator): ... +class Div(operator): ... +class FloorDiv(operator): ... +class LShift(operator): ... +class Mod(operator): ... +class Mult(operator): ... +class MatMult(operator): ... +class Pow(operator): ... +class RShift(operator): ... +class Sub(operator): ... + +class unaryop(AST): + ... + +class Invert(unaryop): ... +class Not(unaryop): ... +class UAdd(unaryop): ... +class USub(unaryop): ... + +class cmpop(AST): + ... + +class Eq(cmpop): ... +class Gt(cmpop): ... +class GtE(cmpop): ... +class In(cmpop): ... +class Is(cmpop): ... +class IsNot(cmpop): ... +class Lt(cmpop): ... +class LtE(cmpop): ... +class NotEq(cmpop): ... +class NotIn(cmpop): ... + + +class comprehension(AST): + target = ... # type: expr + iter = ... # type: expr + ifs = ... # type: typing.List[expr] + + +class ExceptHandler(AST): + type = ... # type: Optional[expr] + name = ... # type: Optional[identifier] + body = ... # type: typing.List[stmt] + lineno = ... # type: int + col_offset = ... # type: int + + +class arguments(AST): + args = ... # type: typing.List[arg] + vararg = ... # type: Optional[arg] + kwonlyargs = ... # type: typing.List[arg] + kw_defaults = ... # type: typing.List[expr] + kwarg = ... # type: Optional[arg] + defaults = ... # type: typing.List[expr] + +class arg(AST): + arg = ... # type: identifier + annotation = ... # type: Optional[expr] + lineno = ... # type: int + col_offset = ... # type: int + +class keyword(AST): + arg = ... # type: Optional[identifier] + value = ... # type: expr + +class alias(AST): + name = ... # type: identifier + asname = ... # type: Optional[identifier] + +class withitem(AST): + context_expr = ... # type: expr + optional_vars = ... # type: Optional[expr] diff --git a/stdlib/3/ast.pyi b/stdlib/3/ast.pyi new file mode 100644 index 000000000..ac803687a --- /dev/null +++ b/stdlib/3/ast.pyi @@ -0,0 +1,42 @@ +# Python 3.5 ast + +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 +) + +class NodeVisitor(): + __doc__ = ... # type: str + def visit(self, node: AST) -> Any: ... + def generic_visit(self, node: AST) -> None: ... + +class NodeTransformer(NodeVisitor): + __doc__ = ... # type: str + def generic_visit(self, node: AST) -> None: ... + +def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ... +def copy_location(new_node: AST, old_node: AST) -> AST: ... +def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ... +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 literal_eval(node_or_string: Union[str, AST]) -> Any: ... +def walk(node: AST) -> Iterator[AST]: ... + +PyCF_ONLY_AST = ... # type: int + diff --git a/third_party/3/typed_ast/ast27.pyi b/third_party/3/typed_ast/ast27.pyi index a2f325253..40b44da83 100644 --- a/third_party/3/typed_ast/ast27.pyi +++ b/third_party/3/typed_ast/ast27.pyi @@ -1,13 +1,12 @@ import typing -from typing import Any, Optional, Union, TypeVar, Generic, Iterator +from typing import Any, Optional, Union, Generic, Iterator -T = TypeVar("T") -class NodeVisitor(Generic[T]): +class NodeVisitor(): __doc__ = ... # type: str - def visit(self, node: AST) -> T: ... + def visit(self, node: AST) -> Any: ... def generic_visit(self, node: AST) -> None: ... -class NodeTransformer(NodeVisitor, Generic[T]): +class NodeTransformer(NodeVisitor): __doc__ = ... # type: str def generic_visit(self, node: AST) -> None: ... @@ -31,13 +30,10 @@ identifier = str class AST: _attributes = ... # type: typing.Tuple[str, ...] _fields = ... # type: typing.Tuple[str, ...] - def __init__(self, *args, **kwargs): ... - def __delattr__(self, name): ... - def __reduce__(self): ... - def __setattr__(self, name, value): ... + def __init__(self, *args, **kwargs) -> None: ... class mod(AST): - pass + ... class Module(mod): body = ... # type: typing.List[stmt] @@ -155,13 +151,13 @@ class Global(stmt): class Expr(stmt): value = ... # type: expr -class Pass(stmt): pass -class Break(stmt): pass -class Continue(stmt): pass +class Pass(stmt): ... +class Break(stmt): ... +class Continue(stmt): ... class slice(AST): - pass + ... _slice = slice # this lets us type the variable named 'slice' below @@ -176,7 +172,7 @@ class ExtSlice(slice): class Index(slice): value = ... # type: expr -class Ellipsis(slice): pass +class Ellipsis(slice): ... class expr(AST): @@ -277,59 +273,59 @@ class Tuple(expr): class expr_context(AST): - pass + ... -class AugLoad(expr_context): pass -class AugStore(expr_context): pass -class Del(expr_context): pass -class Load(expr_context): pass -class Param(expr_context): pass -class Store(expr_context): pass +class AugLoad(expr_context): ... +class AugStore(expr_context): ... +class Del(expr_context): ... +class Load(expr_context): ... +class Param(expr_context): ... +class Store(expr_context): ... class boolop(AST): - pass + ... -class And(boolop): pass -class Or(boolop): pass +class And(boolop): ... +class Or(boolop): ... class operator(AST): - pass + ... -class Add(operator): pass -class BitAnd(operator): pass -class BitOr(operator): pass -class BitXor(operator): pass -class Div(operator): pass -class FloorDiv(operator): pass -class LShift(operator): pass -class Mod(operator): pass -class Mult(operator): pass -class Pow(operator): pass -class RShift(operator): pass -class Sub(operator): pass +class Add(operator): ... +class BitAnd(operator): ... +class BitOr(operator): ... +class BitXor(operator): ... +class Div(operator): ... +class FloorDiv(operator): ... +class LShift(operator): ... +class Mod(operator): ... +class Mult(operator): ... +class Pow(operator): ... +class RShift(operator): ... +class Sub(operator): ... class unaryop(AST): - pass + ... -class Invert(unaryop): pass -class Not(unaryop): pass -class UAdd(unaryop): pass -class USub(unaryop): pass +class Invert(unaryop): ... +class Not(unaryop): ... +class UAdd(unaryop): ... +class USub(unaryop): ... class cmpop(AST): - pass + ... -class Eq(cmpop): pass -class Gt(cmpop): pass -class GtE(cmpop): pass -class In(cmpop): pass -class Is(cmpop): pass -class IsNot(cmpop): pass -class Lt(cmpop): pass -class LtE(cmpop): pass -class NotEq(cmpop): pass -class NotIn(cmpop): pass +class Eq(cmpop): ... +class Gt(cmpop): ... +class GtE(cmpop): ... +class In(cmpop): ... +class Is(cmpop): ... +class IsNot(cmpop): ... +class Lt(cmpop): ... +class LtE(cmpop): ... +class NotEq(cmpop): ... +class NotIn(cmpop): ... class comprehension(AST): diff --git a/third_party/3/typed_ast/ast35.pyi b/third_party/3/typed_ast/ast35.pyi index 7fdae0a77..738ac7d8b 100644 --- a/third_party/3/typed_ast/ast35.pyi +++ b/third_party/3/typed_ast/ast35.pyi @@ -1,13 +1,12 @@ import typing -from typing import Any, Optional, Union, TypeVar, Generic, Iterator +from typing import Any, Optional, Union, Generic, Iterator -T = TypeVar("T") -class NodeVisitor(Generic[T]): +class NodeVisitor(): __doc__ = ... # type: str - def visit(self, node: AST) -> T: ... + def visit(self, node: AST) -> Any: ... def generic_visit(self, node: AST) -> None: ... -class NodeTransformer(NodeVisitor, Generic[T]): +class NodeTransformer(NodeVisitor): __doc__ = ... # type: str def generic_visit(self, node: AST) -> None: ... @@ -31,13 +30,10 @@ identifier = str class AST: _attributes = ... # type: typing.Tuple[str, ...] _fields = ... # type: typing.Tuple[str, ...] - def __init__(self, *args, **kwargs): ... - def __delattr__(self, name): ... - def __reduce__(self): ... - def __setattr__(self, name, value): ... + def __init__(self, *args, **kwargs) -> None: ... class mod(AST): - pass + ... class Module(mod): body = ... # type: typing.List[stmt] @@ -163,13 +159,13 @@ class Nonlocal(stmt): class Expr(stmt): value = ... # type: expr -class Pass(stmt): pass -class Break(stmt): pass -class Continue(stmt): pass +class Pass(stmt): ... +class Break(stmt): ... +class Continue(stmt): ... class slice(AST): - pass + ... _slice = slice # this lets us type the variable named 'slice' below @@ -266,7 +262,7 @@ class Bytes(expr): class NameConstant(expr): value = ... # type: Any -class Ellipsis(expr): pass +class Ellipsis(expr): ... class Attribute(expr): value = ... # type: expr @@ -296,60 +292,60 @@ class Tuple(expr): class expr_context(AST): - pass + ... -class AugLoad(expr_context): pass -class AugStore(expr_context): pass -class Del(expr_context): pass -class Load(expr_context): pass -class Param(expr_context): pass -class Store(expr_context): pass +class AugLoad(expr_context): ... +class AugStore(expr_context): ... +class Del(expr_context): ... +class Load(expr_context): ... +class Param(expr_context): ... +class Store(expr_context): ... class boolop(AST): - pass + ... -class And(boolop): pass -class Or(boolop): pass +class And(boolop): ... +class Or(boolop): ... class operator(AST): - pass + ... -class Add(operator): pass -class BitAnd(operator): pass -class BitOr(operator): pass -class BitXor(operator): pass -class Div(operator): pass -class FloorDiv(operator): pass -class LShift(operator): pass -class Mod(operator): pass -class Mult(operator): pass -class MatMult(operator): pass -class Pow(operator): pass -class RShift(operator): pass -class Sub(operator): pass +class Add(operator): ... +class BitAnd(operator): ... +class BitOr(operator): ... +class BitXor(operator): ... +class Div(operator): ... +class FloorDiv(operator): ... +class LShift(operator): ... +class Mod(operator): ... +class Mult(operator): ... +class MatMult(operator): ... +class Pow(operator): ... +class RShift(operator): ... +class Sub(operator): ... class unaryop(AST): - pass + ... -class Invert(unaryop): pass -class Not(unaryop): pass -class UAdd(unaryop): pass -class USub(unaryop): pass +class Invert(unaryop): ... +class Not(unaryop): ... +class UAdd(unaryop): ... +class USub(unaryop): ... class cmpop(AST): - pass + ... -class Eq(cmpop): pass -class Gt(cmpop): pass -class GtE(cmpop): pass -class In(cmpop): pass -class Is(cmpop): pass -class IsNot(cmpop): pass -class Lt(cmpop): pass -class LtE(cmpop): pass -class NotEq(cmpop): pass -class NotIn(cmpop): pass +class Eq(cmpop): ... +class Gt(cmpop): ... +class GtE(cmpop): ... +class In(cmpop): ... +class Is(cmpop): ... +class IsNot(cmpop): ... +class Lt(cmpop): ... +class LtE(cmpop): ... +class NotEq(cmpop): ... +class NotIn(cmpop): ... class comprehension(AST):