From b1aaab451c123a2956f6d5e4aa4b2054c2880459 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 8 Oct 2019 14:26:41 +0200 Subject: [PATCH 1/3] Remove unused type ignores --- stdlib/2/UserString.pyi | 2 +- stdlib/2/__builtin__.pyi | 17 ++++++----------- stdlib/2and3/builtins.pyi | 17 ++++++----------- stdlib/3/ast.pyi | 2 +- stdlib/3/configparser.pyi | 2 +- stdlib/3/enum.pyi | 2 +- stdlib/3/multiprocessing/context.pyi | 8 ++++---- third_party/2/enum.pyi | 2 +- 8 files changed, 21 insertions(+), 31 deletions(-) diff --git a/stdlib/2/UserString.pyi b/stdlib/2/UserString.pyi index 8cbbfc1242e7..704a93bc0962 100644 --- a/stdlib/2/UserString.pyi +++ b/stdlib/2/UserString.pyi @@ -62,7 +62,7 @@ class UserString(Sequence[UserString]): def upper(self: _UST) -> _UST: ... def zfill(self: _UST, width: int) -> _UST: ... -class MutableString(UserString, MutableSequence[MutableString]): # type: ignore +class MutableString(UserString, MutableSequence[MutableString]): @overload def __getitem__(self: _MST, i: int) -> _MST: ... @overload diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 966e150897eb..540134369a61 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -1160,20 +1160,15 @@ if sys.version_info >= (3,): def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> Iterator[_T]: ... else: @overload - def filter(__function: Callable[[AnyStr], Any], # type: ignore - __iterable: AnyStr) -> AnyStr: ... + def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore @overload - def filter(__function: None, # type: ignore - __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... + def filter(__function: None, __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... # type: ignore @overload - def filter(__function: Callable[[_T], Any], # type: ignore - __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... + def filter(__function: Callable[[_T], Any], __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... # type: ignore @overload - def filter(__function: None, - __iterable: Iterable[Optional[_T]]) -> List[_T]: ... + def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ... @overload - def filter(__function: Callable[[_T], Any], - __iterable: Iterable[_T]) -> List[_T]: ... + def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... def format(__o: object, __format_spec: str = ...) -> str: ... # TODO unicode def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ... def globals() -> Dict[str, Any]: ... @@ -1383,7 +1378,7 @@ if sys.version_info >= (3,): @overload def round(number: SupportsRound[_T]) -> int: ... @overload - def round(number: SupportsRound[_T], ndigits: None) -> int: ... # type: ignore + def round(number: SupportsRound[_T], ndigits: None) -> int: ... @overload def round(number: SupportsRound[_T], ndigits: int) -> _T: ... else: diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 966e150897eb..540134369a61 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -1160,20 +1160,15 @@ if sys.version_info >= (3,): def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> Iterator[_T]: ... else: @overload - def filter(__function: Callable[[AnyStr], Any], # type: ignore - __iterable: AnyStr) -> AnyStr: ... + def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore @overload - def filter(__function: None, # type: ignore - __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... + def filter(__function: None, __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... # type: ignore @overload - def filter(__function: Callable[[_T], Any], # type: ignore - __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... + def filter(__function: Callable[[_T], Any], __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... # type: ignore @overload - def filter(__function: None, - __iterable: Iterable[Optional[_T]]) -> List[_T]: ... + def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ... @overload - def filter(__function: Callable[[_T], Any], - __iterable: Iterable[_T]) -> List[_T]: ... + def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... def format(__o: object, __format_spec: str = ...) -> str: ... # TODO unicode def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ... def globals() -> Dict[str, Any]: ... @@ -1383,7 +1378,7 @@ if sys.version_info >= (3,): @overload def round(number: SupportsRound[_T]) -> int: ... @overload - def round(number: SupportsRound[_T], ndigits: None) -> int: ... # type: ignore + def round(number: SupportsRound[_T], ndigits: None) -> int: ... @overload def round(number: SupportsRound[_T], ndigits: int) -> _T: ... else: diff --git a/stdlib/3/ast.pyi b/stdlib/3/ast.pyi index 8e89b2486d94..416c4fdbf71b 100644 --- a/stdlib/3/ast.pyi +++ b/stdlib/3/ast.pyi @@ -9,7 +9,7 @@ from typing import overload, Any, Iterator, Optional, Union, TypeVar # is imported in both modules. unfortunately we can't just rename sys, # since mypy only supports version checks with a sys that is named # sys. -from _ast import * # type: ignore +from _ast import * if sys.version_info >= (3, 8): from typing import Literal diff --git a/stdlib/3/configparser.pyi b/stdlib/3/configparser.pyi index 8b87e06453b9..24f817997ff7 100644 --- a/stdlib/3/configparser.pyi +++ b/stdlib/3/configparser.pyi @@ -115,7 +115,7 @@ class RawConfigParser(_parser): @overload # type: ignore def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> str: ... - @overload # type: ignore + @overload def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T) -> Union[str, _T]: ... @overload diff --git a/stdlib/3/enum.pyi b/stdlib/3/enum.pyi index 703c7cfa8be3..3cf250fead2b 100644 --- a/stdlib/3/enum.pyi +++ b/stdlib/3/enum.pyi @@ -68,7 +68,7 @@ if sys.version_info >= (3, 6): # The `type: ignore` comment is needed because mypy considers the type # signatures of several methods defined in int and Flag to be incompatible. - class IntFlag(int, Flag): # type: ignore + class IntFlag(int, Flag): def __or__(self: _T, other: Union[int, _T]) -> _T: ... def __and__(self: _T, other: Union[int, _T]) -> _T: ... def __xor__(self: _T, other: Union[int, _T]) -> _T: ... diff --git a/stdlib/3/multiprocessing/context.pyi b/stdlib/3/multiprocessing/context.pyi index 2cdeb07d14cc..e5d6600a40c2 100644 --- a/stdlib/3/multiprocessing/context.pyi +++ b/stdlib/3/multiprocessing/context.pyi @@ -131,19 +131,19 @@ class DefaultContext(object): if sys.platform != 'win32': # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class ForkProcess(Any): # type: ignore + class ForkProcess(Any): _start_method: str @staticmethod def _Popen(process_obj: Any) -> Any: ... # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class SpawnProcess(Any): # type: ignore + class SpawnProcess(Any): _start_method: str @staticmethod def _Popen(process_obj: Any) -> SpawnProcess: ... # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class ForkServerProcess(Any): # type: ignore + class ForkServerProcess(Any): _start_method: str @staticmethod def _Popen(process_obj: Any) -> Any: ... @@ -161,7 +161,7 @@ if sys.platform != 'win32': Process: Type[ForkServerProcess] else: # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class SpawnProcess(Any): # type: ignore + class SpawnProcess(Any): _start_method: str @staticmethod # TODO: type should be BaseProcess once a stub in multiprocessing.process exists diff --git a/third_party/2/enum.pyi b/third_party/2/enum.pyi index 703c7cfa8be3..3cf250fead2b 100644 --- a/third_party/2/enum.pyi +++ b/third_party/2/enum.pyi @@ -68,7 +68,7 @@ if sys.version_info >= (3, 6): # The `type: ignore` comment is needed because mypy considers the type # signatures of several methods defined in int and Flag to be incompatible. - class IntFlag(int, Flag): # type: ignore + class IntFlag(int, Flag): def __or__(self: _T, other: Union[int, _T]) -> _T: ... def __and__(self: _T, other: Union[int, _T]) -> _T: ... def __xor__(self: _T, other: Union[int, _T]) -> _T: ... From 93acc2089b62980842cb47de1bff7531afc667c9 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 8 Oct 2019 17:23:24 +0200 Subject: [PATCH 2/3] Remove obsolete comment --- stdlib/3/enum.pyi | 2 -- third_party/2/enum.pyi | 2 -- 2 files changed, 4 deletions(-) diff --git a/stdlib/3/enum.pyi b/stdlib/3/enum.pyi index 3cf250fead2b..be22d386dbc7 100644 --- a/stdlib/3/enum.pyi +++ b/stdlib/3/enum.pyi @@ -66,8 +66,6 @@ if sys.version_info >= (3, 6): def __xor__(self: _T, other: _T) -> _T: ... def __invert__(self: _T) -> _T: ... - # The `type: ignore` comment is needed because mypy considers the type - # signatures of several methods defined in int and Flag to be incompatible. class IntFlag(int, Flag): def __or__(self: _T, other: Union[int, _T]) -> _T: ... def __and__(self: _T, other: Union[int, _T]) -> _T: ... diff --git a/third_party/2/enum.pyi b/third_party/2/enum.pyi index 3cf250fead2b..be22d386dbc7 100644 --- a/third_party/2/enum.pyi +++ b/third_party/2/enum.pyi @@ -66,8 +66,6 @@ if sys.version_info >= (3, 6): def __xor__(self: _T, other: _T) -> _T: ... def __invert__(self: _T) -> _T: ... - # The `type: ignore` comment is needed because mypy considers the type - # signatures of several methods defined in int and Flag to be incompatible. class IntFlag(int, Flag): def __or__(self: _T, other: Union[int, _T]) -> _T: ... def __and__(self: _T, other: Union[int, _T]) -> _T: ... From 6878a0433640d811892b5b73656196f8e16a0de7 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 9 Oct 2019 08:40:19 +0200 Subject: [PATCH 3/3] Re-adding type ignore in ast.pyi --- stdlib/3/ast.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/ast.pyi b/stdlib/3/ast.pyi index 416c4fdbf71b..8e89b2486d94 100644 --- a/stdlib/3/ast.pyi +++ b/stdlib/3/ast.pyi @@ -9,7 +9,7 @@ from typing import overload, Any, Iterator, Optional, Union, TypeVar # is imported in both modules. unfortunately we can't just rename sys, # since mypy only supports version checks with a sys that is named # sys. -from _ast import * +from _ast import * # type: ignore if sys.version_info >= (3, 8): from typing import Literal