From 0cf9a38eb84cc54bb99a9326f84903ce50662c15 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 1 Jan 2021 06:00:09 -0800 Subject: [PATCH] Addressed minor errors caught by pyright in stdlib stubs (#4880) * Removed unused import symbols from stdlib stubs and fixed a few other errors detected by pyright. I did a similar pass several months ago; these were introduced since then. * Added a few missing types and type arguments. Removed unused import statement. Removed default values that caused overloads to have overlapping signatures. Co-authored-by: Eric Traut --- stdlib/3/concurrent/futures/thread.pyi | 4 ++-- stdlib/3/distutils/command/upload.pyi | 2 +- stdlib/3/http/cookiejar.pyi | 2 +- stdlib/3/importlib/abc.pyi | 2 +- stdlib/3/os/__init__.pyi | 2 +- stdlib/3/unittest/mock.pyi | 2 +- stdlib/3/winreg.pyi | 1 - 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/stdlib/3/concurrent/futures/thread.pyi b/stdlib/3/concurrent/futures/thread.pyi index e8116c6da..aedfe5d05 100644 --- a/stdlib/3/concurrent/futures/thread.pyi +++ b/stdlib/3/concurrent/futures/thread.pyi @@ -15,9 +15,9 @@ _S = TypeVar("_S") class ThreadPoolExecutor(Executor): if sys.version_info >= (3, 7): - _work_queue: queue.SimpleQueue + _work_queue: queue.SimpleQueue[Any] else: - _work_queue: queue.Queue + _work_queue: queue.Queue[Any] if sys.version_info >= (3, 7): def __init__( self, diff --git a/stdlib/3/distutils/command/upload.pyi b/stdlib/3/distutils/command/upload.pyi index a30fabb18..ef4bbc332 100644 --- a/stdlib/3/distutils/command/upload.pyi +++ b/stdlib/3/distutils/command/upload.pyi @@ -5,4 +5,4 @@ class upload(PyPIRCCommand): description: ClassVar[str] boolean_options: ClassVar[List[str]] def run(self) -> None: ... - def upload_file(self, command, pyversion, filename) -> None: ... + def upload_file(self, command: str, pyversion: str, filename: str) -> None: ... diff --git a/stdlib/3/http/cookiejar.pyi b/stdlib/3/http/cookiejar.pyi index 7ff7544ad..310ccee71 100644 --- a/stdlib/3/http/cookiejar.pyi +++ b/stdlib/3/http/cookiejar.pyi @@ -124,6 +124,6 @@ class Cookie: @overload def get_nonstandard_attr(self, name: str) -> Optional[str]: ... @overload - def get_nonstandard_attr(self, name: str, default: _T = ...) -> Union[str, _T]: ... + def get_nonstandard_attr(self, name: str, default: _T) -> Union[str, _T]: ... def set_nonstandard_attr(self, name: str, value: str) -> None: ... def is_expired(self, now: int = ...) -> bool: ... diff --git a/stdlib/3/importlib/abc.pyi b/stdlib/3/importlib/abc.pyi index 507d3a596..0949d317c 100644 --- a/stdlib/3/importlib/abc.pyi +++ b/stdlib/3/importlib/abc.pyi @@ -91,7 +91,7 @@ if sys.version_info >= (3, 9): @abstractmethod def __truediv__(self, child: Traversable) -> Traversable: ... @abstractmethod - def open(self, mode: Literal["r", "rb"] = ..., *args: Any, **kwargs: Any) -> IO: ... + def open(self, mode: Literal["r", "rb"] = ..., *args: Any, **kwargs: Any) -> IO[Any]: ... @property @abstractmethod def name(self) -> str: ... diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index a311b174c..7df622984 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -390,7 +390,7 @@ if sys.platform != "win32": @overload def getenvb(key: bytes) -> Optional[bytes]: ... @overload - def getenvb(key: bytes, default: _T = ...) -> Union[bytes, _T]: ... + def getenvb(key: bytes, default: _T) -> Union[bytes, _T]: ... def putenv(__name: Union[bytes, str], __value: Union[bytes, str]) -> None: ... diff --git a/stdlib/3/unittest/mock.pyi b/stdlib/3/unittest/mock.pyi index bfeba5739..cfa9e38a6 100644 --- a/stdlib/3/unittest/mock.pyi +++ b/stdlib/3/unittest/mock.pyi @@ -387,7 +387,7 @@ if sys.version_info >= (3, 8): def assert_any_await(self, *args: Any, **kwargs: Any) -> None: ... def assert_has_awaits(self, calls: _CallList, any_order: bool = ...) -> None: ... def assert_not_awaited(self) -> None: ... - def reset_mock(self, *args, **kwargs) -> None: ... + def reset_mock(self, *args: Any, **kwargs: Any) -> None: ... await_count: int await_args: Optional[_Call] await_args_list: _CallList diff --git a/stdlib/3/winreg.pyi b/stdlib/3/winreg.pyi index eb28ddd21..8f25dd61a 100644 --- a/stdlib/3/winreg.pyi +++ b/stdlib/3/winreg.pyi @@ -1,4 +1,3 @@ -import sys from types import TracebackType from typing import Any, Optional, Tuple, Type, Union