From 6ba28ae54707db9be1a89119bd6eebcc9237395b Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 23 Feb 2023 20:59:50 +0000 Subject: [PATCH] Remove unused `type: ignore` comments (#9801) --- stdlib/asyncio/base_subprocess.pyi | 2 +- stdlib/asyncio/tasks.pyi | 4 ++-- stdlib/builtins.pyi | 18 +++++++++--------- stdlib/difflib.pyi | 3 +-- stdlib/encodings/utf_8_sig.pyi | 2 +- stdlib/enum.pyi | 2 +- stdlib/gettext.pyi | 4 ++-- stdlib/http/client.pyi | 2 +- stdlib/importlib/abc.pyi | 2 +- stdlib/socket.pyi | 6 +++--- stdlib/socketserver.pyi | 2 +- stdlib/typing.pyi | 2 +- stdlib/unittest/case.pyi | 8 ++++---- stubs/cachetools/cachetools/__init__.pyi | 2 +- .../rfc6749/clients/backend_application.pyi | 2 +- .../rfc6749/clients/legacy_application.pyi | 2 +- .../rfc6749/clients/mobile_application.pyi | 4 ++-- .../rfc6749/clients/service_application.pyi | 2 +- .../oauth2/rfc6749/clients/web_application.pyi | 6 +++--- stubs/psycopg2/psycopg2/extras.pyi | 4 ++-- 20 files changed, 39 insertions(+), 40 deletions(-) diff --git a/stdlib/asyncio/base_subprocess.pyi b/stdlib/asyncio/base_subprocess.pyi index 597c83029..8f262cd5c 100644 --- a/stdlib/asyncio/base_subprocess.pyi +++ b/stdlib/asyncio/base_subprocess.pyi @@ -46,7 +46,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): def get_pid(self) -> int | None: ... # type: ignore[override] def get_pipe_transport(self, fd: int) -> _File: ... # type: ignore[override] def _check_proc(self) -> None: ... # undocumented - def send_signal(self, signal: int) -> None: ... # type: ignore[override] + def send_signal(self, signal: int) -> None: ... async def _connect_pipes(self, waiter: futures.Future[Any] | None) -> None: ... # undocumented def _call(self, cb: Callable[..., object], *data: Any) -> None: ... # undocumented def _pipe_connection_lost(self, fd: int, exc: BaseException | None) -> None: ... # undocumented diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index 0a44255a3..308453709 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -140,7 +140,7 @@ if sys.version_info >= (3, 10): tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] ]: ... @overload - def gather(*coros_or_futures: _FutureLike[Any], return_exceptions: bool = False) -> Future[list[Any]]: ... # type: ignore[misc] + def gather(*coros_or_futures: _FutureLike[Any], return_exceptions: bool = False) -> Future[list[Any]]: ... else: @overload @@ -230,7 +230,7 @@ else: tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] ]: ... @overload - def gather( # type: ignore[misc] + def gather( *coros_or_futures: _FutureLike[Any], loop: AbstractEventLoop | None = None, return_exceptions: bool = False ) -> Future[list[Any]]: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 511fa4d54..c2d98407d 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -447,7 +447,7 @@ class str(Sequence[str]): @overload def format(self: LiteralString, *args: LiteralString, **kwargs: LiteralString) -> LiteralString: ... @overload - def format(self, *args: object, **kwargs: object) -> str: ... # type: ignore[misc] + def format(self, *args: object, **kwargs: object) -> str: ... def format_map(self, map: _FormatMapMapping) -> str: ... def index(self, __sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...) -> int: ... def isalnum(self) -> bool: ... @@ -577,7 +577,7 @@ class str(Sequence[str]): @overload def __mod__(self: LiteralString, __x: LiteralString | tuple[LiteralString, ...]) -> LiteralString: ... @overload - def __mod__(self, __x: Any) -> str: ... # type: ignore[misc] + def __mod__(self, __x: Any) -> str: ... @overload def __mul__(self: LiteralString, __n: SupportsIndex) -> LiteralString: ... @overload @@ -1192,7 +1192,7 @@ class property: def __delete__(self, __instance: Any) -> None: ... @final -class _NotImplementedType(Any): # type: ignore[misc] +class _NotImplementedType(Any): # A little weird, but typing the __call__ as NotImplemented makes the error message # for NotImplemented() much better __call__: NotImplemented # type: ignore[valid-type] # pyright: ignore[reportGeneralTypeIssues] @@ -1613,11 +1613,11 @@ if sys.version_info >= (3, 8): @overload def pow(base: int, exp: int, mod: int) -> int: ... @overload - def pow(base: int, exp: Literal[0], mod: None = None) -> Literal[1]: ... # type: ignore[misc] + def pow(base: int, exp: Literal[0], mod: None = None) -> Literal[1]: ... @overload - def pow(base: int, exp: _PositiveInteger, mod: None = None) -> int: ... # type: ignore[misc] + def pow(base: int, exp: _PositiveInteger, mod: None = None) -> int: ... @overload - def pow(base: int, exp: _NegativeInteger, mod: None = None) -> float: ... # type: ignore[misc] + def pow(base: int, exp: _NegativeInteger, mod: None = None) -> float: ... # int base & positive-int exp -> int; int base & negative-int exp -> float # return type must be Any as `int | float` causes too many false-positive errors @overload @@ -1650,11 +1650,11 @@ else: @overload def pow(__base: int, __exp: int, __mod: int) -> int: ... @overload - def pow(__base: int, __exp: Literal[0], __mod: None = None) -> Literal[1]: ... # type: ignore[misc] + def pow(__base: int, __exp: Literal[0], __mod: None = None) -> Literal[1]: ... @overload - def pow(__base: int, __exp: _PositiveInteger, __mod: None = None) -> int: ... # type: ignore[misc] + def pow(__base: int, __exp: _PositiveInteger, __mod: None = None) -> int: ... @overload - def pow(__base: int, __exp: _NegativeInteger, __mod: None = None) -> float: ... # type: ignore[misc] + def pow(__base: int, __exp: _NegativeInteger, __mod: None = None) -> float: ... @overload def pow(__base: int, __exp: int, __mod: None = None) -> Any: ... @overload diff --git a/stdlib/difflib.pyi b/stdlib/difflib.pyi index 310519602..894ebaaec 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -57,9 +57,8 @@ class SequenceMatcher(Generic[_T]): if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... -# mypy thinks the signatures of the overloads overlap, but the types still work fine @overload -def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], n: int = 3, cutoff: float = 0.6) -> list[AnyStr]: ... # type: ignore[misc] +def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], n: int = 3, cutoff: float = 0.6) -> list[AnyStr]: ... @overload def get_close_matches( word: Sequence[_T], possibilities: Iterable[Sequence[_T]], n: int = 3, cutoff: float = 0.6 diff --git a/stdlib/encodings/utf_8_sig.pyi b/stdlib/encodings/utf_8_sig.pyi index 150fe22f8..af69217d6 100644 --- a/stdlib/encodings/utf_8_sig.pyi +++ b/stdlib/encodings/utf_8_sig.pyi @@ -4,7 +4,7 @@ from _typeshed import ReadableBuffer class IncrementalEncoder(codecs.IncrementalEncoder): def __init__(self, errors: str = "strict") -> None: ... def encode(self, input: str, final: bool = False) -> bytes: ... - def getstate(self) -> int: ... # type: ignore[override] + def getstate(self) -> int: ... def setstate(self, state: int) -> None: ... # type: ignore[override] class IncrementalDecoder(codecs.BufferedIncrementalDecoder): diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index b46fe429c..fd9bb6450 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -114,7 +114,7 @@ class EnumMeta(ABCMeta): def __bool__(self) -> Literal[True]: ... def __dir__(self) -> list[str]: ... # Simple value lookup - @overload # type: ignore[override] + @overload def __call__(cls: type[_EnumMemberT], value: Any, names: None = None) -> _EnumMemberT: ... # Functional Enum API if sys.version_info >= (3, 11): diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index 5d98227ec..57e81120b 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -57,8 +57,8 @@ class GNUTranslations(NullTranslations): CONTEXT: str VERSIONS: Sequence[int] -@overload # ignores incompatible overloads -def find( # type: ignore[misc] +@overload +def find( domain: str, localedir: StrPath | None = None, languages: Iterable[str] | None = None, all: Literal[False] = False ) -> str | None: ... @overload diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index b1506b50e..1f16bdc2d 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -174,7 +174,7 @@ class HTTPConnection: class HTTPSConnection(HTTPConnection): # Can be `None` if `.connect()` was not called: - sock: ssl.SSLSocket | Any # type: ignore[override] + sock: ssl.SSLSocket | Any def __init__( self, host: str, diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 3d0c2d38c..4fe2fed27 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -191,7 +191,7 @@ if sys.version_info >= (3, 9): class TraversableResources(ResourceReader): @abstractmethod def files(self) -> Traversable: ... - def open_resource(self, resource: str) -> BufferedReader: ... # type: ignore[override] + def open_resource(self, resource: str) -> BufferedReader: ... def resource_path(self, resource: Any) -> NoReturn: ... def is_resource(self, path: str) -> bool: ... def contents(self) -> Iterator[str]: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index dbc1d46ec..6c897b919 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -664,7 +664,7 @@ class socket(_socket.socket): # Note that the makefile's documented windows-specific behavior is not represented # mode strings with duplicates are intentionally excluded @overload - def makefile( # type: ignore[misc] + def makefile( self, mode: Literal["b", "rb", "br", "wb", "bw", "rwb", "rbw", "wrb", "wbr", "brw", "bwr"], buffering: Literal[0], @@ -725,9 +725,9 @@ class socket(_socket.socket): ) -> TextIOWrapper: ... def sendfile(self, file: _SendableFile, offset: int = 0, count: int | None = None) -> int: ... @property - def family(self) -> AddressFamily: ... # type: ignore[override] + def family(self) -> AddressFamily: ... @property - def type(self) -> SocketKind: ... # type: ignore[override] + def type(self) -> SocketKind: ... def get_inheritable(self) -> bool: ... def set_inheritable(self, inheritable: bool) -> None: ... diff --git a/stdlib/socketserver.pyi b/stdlib/socketserver.pyi index 3d7e77f4c..d04005643 100644 --- a/stdlib/socketserver.pyi +++ b/stdlib/socketserver.pyi @@ -70,7 +70,7 @@ class BaseServer: class TCPServer(BaseServer): if sys.version_info >= (3, 11): allow_reuse_port: bool - server_address: _AfInetAddress # type: ignore[assignment] + server_address: _AfInetAddress def __init__( self, server_address: _AfInetAddress, diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 2cbb7c812..031acc7b9 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -254,7 +254,7 @@ _T_contra = TypeVar("_T_contra", contravariant=True) # Ditto contravariant. _TC = TypeVar("_TC", bound=Type[object]) def no_type_check(arg: _F) -> _F: ... -def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ... # type: ignore[misc] +def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ... # Type aliases and type constructors diff --git a/stdlib/unittest/case.pyi b/stdlib/unittest/case.pyi index b118ecfca..2f33a80ed 100644 --- a/stdlib/unittest/case.pyi +++ b/stdlib/unittest/case.pyi @@ -132,7 +132,7 @@ class TestCase: # are not using `ParamSpec` intentionally, # because they might be used with explicitly wrong arg types to raise some error in tests. @overload - def assertRaises( # type: ignore[misc] + def assertRaises( self, expected_exception: type[BaseException] | tuple[type[BaseException], ...], callable: Callable[..., Any], @@ -144,7 +144,7 @@ class TestCase: self, expected_exception: type[_E] | tuple[type[_E], ...], *, msg: Any = ... ) -> _AssertRaisesContext[_E]: ... @overload - def assertRaisesRegex( # type: ignore[misc] + def assertRaisesRegex( self, expected_exception: type[BaseException] | tuple[type[BaseException], ...], expected_regex: str | Pattern[str], @@ -157,7 +157,7 @@ class TestCase: self, expected_exception: type[_E] | tuple[type[_E], ...], expected_regex: str | Pattern[str], *, msg: Any = ... ) -> _AssertRaisesContext[_E]: ... @overload - def assertWarns( # type: ignore[misc] + def assertWarns( self, expected_warning: type[Warning] | tuple[type[Warning], ...], callable: Callable[_P, Any], @@ -169,7 +169,7 @@ class TestCase: self, expected_warning: type[Warning] | tuple[type[Warning], ...], *, msg: Any = ... ) -> _AssertWarnsContext: ... @overload - def assertWarnsRegex( # type: ignore[misc] + def assertWarnsRegex( self, expected_warning: type[Warning] | tuple[type[Warning], ...], expected_regex: str | Pattern[str], diff --git a/stubs/cachetools/cachetools/__init__.pyi b/stubs/cachetools/cachetools/__init__.pyi index 06fcc5083..56eec3d00 100644 --- a/stubs/cachetools/cachetools/__init__.pyi +++ b/stubs/cachetools/cachetools/__init__.pyi @@ -21,7 +21,7 @@ class Cache(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def __missing__(self, key: _KT) -> _VT: ... def __iter__(self) -> Iterator[_KT]: ... def __len__(self) -> int: ... - @overload # type: ignore[override] + @overload def pop(self, key: _KT) -> _VT: ... @overload def pop(self, key: _KT, default: _VT | _T) -> _VT | _T: ... diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/backend_application.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/backend_application.pyi index c94f999ac..5c6877c16 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/backend_application.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/backend_application.pyi @@ -4,4 +4,4 @@ from .base import Client as Client class BackendApplicationClient(Client): grant_type: str - def prepare_request_body(self, body: str = ..., scope: Incomplete | None = ..., include_client_id: bool = ..., **kwargs): ... # type: ignore[override] + def prepare_request_body(self, body: str = ..., scope: Incomplete | None = ..., include_client_id: bool = ..., **kwargs): ... diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/legacy_application.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/legacy_application.pyi index 48fa83f86..5cc028c99 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/legacy_application.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/legacy_application.pyi @@ -5,6 +5,6 @@ from .base import Client as Client class LegacyApplicationClient(Client): grant_type: str def __init__(self, client_id, **kwargs) -> None: ... - def prepare_request_body( # type: ignore[override] + def prepare_request_body( self, username, password, body: str = ..., scope: Incomplete | None = ..., include_client_id: bool = ..., **kwargs ): ... diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/mobile_application.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/mobile_application.pyi index 7b1223aab..283d45cf4 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/mobile_application.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/mobile_application.pyi @@ -5,8 +5,8 @@ from .base import Client as Client class MobileApplicationClient(Client): response_type: str - def prepare_request_uri( # type: ignore[override] + def prepare_request_uri( self, uri, redirect_uri: Incomplete | None = ..., scope: Incomplete | None = ..., state: Incomplete | None = ..., **kwargs ): ... token: Any - def parse_request_uri_response(self, uri, state: Incomplete | None = ..., scope: Incomplete | None = ...): ... # type: ignore[override] + def parse_request_uri_response(self, uri, state: Incomplete | None = ..., scope: Incomplete | None = ...): ... diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/service_application.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/service_application.pyi index fdbfee5a1..eba9fe18b 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/service_application.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/service_application.pyi @@ -18,7 +18,7 @@ class ServiceApplicationClient(Client): audience: Incomplete | None = ..., **kwargs, ) -> None: ... - def prepare_request_body( # type: ignore[override] + def prepare_request_body( self, private_key: Incomplete | None = ..., subject: Incomplete | None = ..., diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/web_application.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/web_application.pyi index 0198e28ac..c16e9e1ff 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/web_application.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/clients/web_application.pyi @@ -7,7 +7,7 @@ class WebApplicationClient(Client): grant_type: str code: Any def __init__(self, client_id, code: Incomplete | None = ..., **kwargs) -> None: ... - def prepare_request_uri( # type: ignore[override] + def prepare_request_uri( self, uri, redirect_uri: Incomplete | None = ..., @@ -17,7 +17,7 @@ class WebApplicationClient(Client): code_challenge_method: str | None = ..., **kwargs, ): ... - def prepare_request_body( # type: ignore[override] + def prepare_request_body( self, code: Incomplete | None = ..., redirect_uri: Incomplete | None = ..., @@ -26,4 +26,4 @@ class WebApplicationClient(Client): code_verifier: str | None = ..., **kwargs, ): ... - def parse_request_uri_response(self, uri, state: Incomplete | None = ...): ... # type: ignore[override] + def parse_request_uri_response(self, uri, state: Incomplete | None = ...): ... diff --git a/stubs/psycopg2/psycopg2/extras.pyi b/stubs/psycopg2/psycopg2/extras.pyi index 6de89e600..7bce57e8b 100644 --- a/stubs/psycopg2/psycopg2/extras.pyi +++ b/stubs/psycopg2/psycopg2/extras.pyi @@ -132,10 +132,10 @@ class NamedTupleCursor(_cursor): def execute(self, query, vars: Incomplete | None = ...): ... def executemany(self, query, vars): ... def callproc(self, procname, vars: Incomplete | None = ...): ... - def fetchone(self) -> NamedTuple | None: ... # type: ignore[override] + def fetchone(self) -> NamedTuple | None: ... def fetchmany(self, size: int | None = ...) -> list[NamedTuple]: ... # type: ignore[override] def fetchall(self) -> list[NamedTuple]: ... # type: ignore[override] - def __next__(self) -> NamedTuple: ... # type: ignore[override] + def __next__(self) -> NamedTuple: ... class LoggingConnection(_connection): log: Any