From 07df7f65112f2f7ecc6d8ee031c2e867554c4fcb Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Wed, 19 Aug 2020 21:37:49 -0700 Subject: [PATCH 1/2] Added some missing type annotations within third-party stub files --- third_party/3/docutils/__init__.pyi | 2 +- third_party/3/docutils/examples.pyi | 2 +- third_party/3/docutils/nodes.pyi | 4 ++-- third_party/3/docutils/parsers/__init__.pyi | 2 +- third_party/3/docutils/parsers/rst/__init__.pyi | 2 +- third_party/3/docutils/parsers/rst/nodes.pyi | 2 +- third_party/3/docutils/parsers/rst/states.pyi | 2 +- third_party/3/six/__init__.pyi | 13 +++++-------- third_party/3/typed_ast/ast27.pyi | 2 +- third_party/3/typed_ast/ast3.pyi | 2 +- third_party/3/waitress/runner.pyi | 2 +- 11 files changed, 16 insertions(+), 19 deletions(-) diff --git a/third_party/3/docutils/__init__.pyi b/third_party/3/docutils/__init__.pyi index 024e962b10df..e27843e53382 100644 --- a/third_party/3/docutils/__init__.pyi +++ b/third_party/3/docutils/__init__.pyi @@ -1,3 +1,3 @@ from typing import Any -def __getattr__(name) -> Any: ... +def __getattr__(name: str) -> Any: ... diff --git a/third_party/3/docutils/examples.pyi b/third_party/3/docutils/examples.pyi index ec73a299dd22..581ebba7e61e 100644 --- a/third_party/3/docutils/examples.pyi +++ b/third_party/3/docutils/examples.pyi @@ -2,4 +2,4 @@ from typing import Any html_parts: Any -def __getattr__(name) -> Any: ... +def __getattr__(name: str) -> Any: ... diff --git a/third_party/3/docutils/nodes.pyi b/third_party/3/docutils/nodes.pyi index 0c3588c2b0ba..11773347ff87 100644 --- a/third_party/3/docutils/nodes.pyi +++ b/third_party/3/docutils/nodes.pyi @@ -1,6 +1,6 @@ from typing import Any, List class reference: - def __init__(self, rawsource: str = ..., text: str = ..., *children: List[Any], **attributes) -> None: ... + def __init__(self, rawsource: str = ..., text: str = ..., *children: List[Any], **attributes: Any) -> None: ... -def __getattr__(name) -> Any: ... +def __getattr__(name: str) -> Any: ... diff --git a/third_party/3/docutils/parsers/__init__.pyi b/third_party/3/docutils/parsers/__init__.pyi index 024e962b10df..e27843e53382 100644 --- a/third_party/3/docutils/parsers/__init__.pyi +++ b/third_party/3/docutils/parsers/__init__.pyi @@ -1,3 +1,3 @@ from typing import Any -def __getattr__(name) -> Any: ... +def __getattr__(name: str) -> Any: ... diff --git a/third_party/3/docutils/parsers/rst/__init__.pyi b/third_party/3/docutils/parsers/rst/__init__.pyi index 024e962b10df..e27843e53382 100644 --- a/third_party/3/docutils/parsers/rst/__init__.pyi +++ b/third_party/3/docutils/parsers/rst/__init__.pyi @@ -1,3 +1,3 @@ from typing import Any -def __getattr__(name) -> Any: ... +def __getattr__(name: str) -> Any: ... diff --git a/third_party/3/docutils/parsers/rst/nodes.pyi b/third_party/3/docutils/parsers/rst/nodes.pyi index 024e962b10df..e27843e53382 100644 --- a/third_party/3/docutils/parsers/rst/nodes.pyi +++ b/third_party/3/docutils/parsers/rst/nodes.pyi @@ -1,3 +1,3 @@ from typing import Any -def __getattr__(name) -> Any: ... +def __getattr__(name: str) -> Any: ... diff --git a/third_party/3/docutils/parsers/rst/states.pyi b/third_party/3/docutils/parsers/rst/states.pyi index fef8566650ff..ac0872693442 100644 --- a/third_party/3/docutils/parsers/rst/states.pyi +++ b/third_party/3/docutils/parsers/rst/states.pyi @@ -3,4 +3,4 @@ from typing import Any class Inliner: def __init__(self) -> None: ... -def __getattr__(name) -> Any: ... +def __getattr__(name: str) -> Any: ... diff --git a/third_party/3/six/__init__.pyi b/third_party/3/six/__init__.pyi index 952439bef606..7e625558de23 100644 --- a/third_party/3/six/__init__.pyi +++ b/third_party/3/six/__init__.pyi @@ -1,7 +1,6 @@ from __future__ import print_function import types -import typing import unittest from builtins import next as next from functools import wraps as wraps @@ -13,6 +12,7 @@ from typing import ( Dict, ItemsView, Iterable, + Iterator, KeysView, Mapping, NoReturn, @@ -53,18 +53,15 @@ def callable(obj: object) -> bool: ... def get_unbound_function(unbound: types.FunctionType) -> types.FunctionType: ... def create_bound_method(func: types.FunctionType, obj: object) -> types.MethodType: ... def create_unbound_method(func: types.FunctionType, cls: type) -> types.FunctionType: ... - -Iterator = object - def get_method_function(meth: types.MethodType) -> types.FunctionType: ... def get_method_self(meth: types.MethodType) -> Optional[object]: ... def get_function_closure(fun: types.FunctionType) -> Optional[Tuple[types._Cell, ...]]: ... def get_function_code(fun: types.FunctionType) -> types.CodeType: ... def get_function_defaults(fun: types.FunctionType) -> Optional[Tuple[Any, ...]]: ... def get_function_globals(fun: types.FunctionType) -> Dict[str, Any]: ... -def iterkeys(d: Mapping[_K, _V]) -> typing.Iterator[_K]: ... -def itervalues(d: Mapping[_K, _V]) -> typing.Iterator[_V]: ... -def iteritems(d: Mapping[_K, _V]) -> typing.Iterator[Tuple[_K, _V]]: ... +def iterkeys(d: Mapping[_K, _V]) -> Iterator[_K]: ... +def itervalues(d: Mapping[_K, _V]) -> Iterator[_V]: ... +def iteritems(d: Mapping[_K, _V]) -> Iterator[Tuple[_K, _V]]: ... # def iterlists @@ -79,7 +76,7 @@ unichr = chr def int2byte(i: int) -> bytes: ... def byte2int(bs: binary_type) -> int: ... def indexbytes(buf: binary_type, i: int) -> int: ... -def iterbytes(buf: binary_type) -> typing.Iterator[int]: ... +def iterbytes(buf: binary_type) -> Iterator[int]: ... def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: Optional[str] = ...) -> None: ... @overload def assertRaisesRegex(self: unittest.TestCase, msg: Optional[str] = ...) -> Any: ... diff --git a/third_party/3/typed_ast/ast27.pyi b/third_party/3/typed_ast/ast27.pyi index 787f63dfe0dc..760efdbc8e95 100644 --- a/third_party/3/typed_ast/ast27.pyi +++ b/third_party/3/typed_ast/ast27.pyi @@ -28,7 +28,7 @@ identifier = str class AST: _attributes: typing.Tuple[str, ...] _fields: typing.Tuple[str, ...] - def __init__(self, *args, **kwargs) -> None: ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... class mod(AST): ... diff --git a/third_party/3/typed_ast/ast3.pyi b/third_party/3/typed_ast/ast3.pyi index 802f6707cb63..631924cfb386 100644 --- a/third_party/3/typed_ast/ast3.pyi +++ b/third_party/3/typed_ast/ast3.pyi @@ -28,7 +28,7 @@ identifier = str class AST: _attributes: typing.Tuple[str, ...] _fields: typing.Tuple[str, ...] - def __init__(self, *args, **kwargs) -> None: ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... class mod(AST): ... diff --git a/third_party/3/waitress/runner.pyi b/third_party/3/waitress/runner.pyi index f9493e21ee9e..a817771a27db 100644 --- a/third_party/3/waitress/runner.pyi +++ b/third_party/3/waitress/runner.pyi @@ -8,4 +8,4 @@ def match(obj_name: str) -> Tuple[str, str]: ... def resolve(module_name: str, object_name: str) -> Any: ... def show_help(stream: TextIOWrapper, name: str, error: Optional[str] = ...) -> None: ... def show_exception(stream: TextIOWrapper) -> None: ... -def run(argv: Sequence[str] = ..., _serve: Callable[..., Any] = ...): ... +def run(argv: Sequence[str] = ..., _serve: Callable[..., Any] = ...) -> None: ... From c9df33df416d784b27f105c08bb5fbd9a6b8f990 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Thu, 20 Aug 2020 13:02:02 -0700 Subject: [PATCH 2/2] Backed out changes to six stub --- third_party/3/six/__init__.pyi | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/third_party/3/six/__init__.pyi b/third_party/3/six/__init__.pyi index 7e625558de23..952439bef606 100644 --- a/third_party/3/six/__init__.pyi +++ b/third_party/3/six/__init__.pyi @@ -1,6 +1,7 @@ from __future__ import print_function import types +import typing import unittest from builtins import next as next from functools import wraps as wraps @@ -12,7 +13,6 @@ from typing import ( Dict, ItemsView, Iterable, - Iterator, KeysView, Mapping, NoReturn, @@ -53,15 +53,18 @@ def callable(obj: object) -> bool: ... def get_unbound_function(unbound: types.FunctionType) -> types.FunctionType: ... def create_bound_method(func: types.FunctionType, obj: object) -> types.MethodType: ... def create_unbound_method(func: types.FunctionType, cls: type) -> types.FunctionType: ... + +Iterator = object + def get_method_function(meth: types.MethodType) -> types.FunctionType: ... def get_method_self(meth: types.MethodType) -> Optional[object]: ... def get_function_closure(fun: types.FunctionType) -> Optional[Tuple[types._Cell, ...]]: ... def get_function_code(fun: types.FunctionType) -> types.CodeType: ... def get_function_defaults(fun: types.FunctionType) -> Optional[Tuple[Any, ...]]: ... def get_function_globals(fun: types.FunctionType) -> Dict[str, Any]: ... -def iterkeys(d: Mapping[_K, _V]) -> Iterator[_K]: ... -def itervalues(d: Mapping[_K, _V]) -> Iterator[_V]: ... -def iteritems(d: Mapping[_K, _V]) -> Iterator[Tuple[_K, _V]]: ... +def iterkeys(d: Mapping[_K, _V]) -> typing.Iterator[_K]: ... +def itervalues(d: Mapping[_K, _V]) -> typing.Iterator[_V]: ... +def iteritems(d: Mapping[_K, _V]) -> typing.Iterator[Tuple[_K, _V]]: ... # def iterlists @@ -76,7 +79,7 @@ unichr = chr def int2byte(i: int) -> bytes: ... def byte2int(bs: binary_type) -> int: ... def indexbytes(buf: binary_type, i: int) -> int: ... -def iterbytes(buf: binary_type) -> Iterator[int]: ... +def iterbytes(buf: binary_type) -> typing.Iterator[int]: ... def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: Optional[str] = ...) -> None: ... @overload def assertRaisesRegex(self: unittest.TestCase, msg: Optional[str] = ...) -> Any: ...