From a1f16da64ea185f3b53dd3919ff9944cb73a9652 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Tue, 23 Feb 2021 11:46:53 -0700 Subject: [PATCH] Added some missing parameter annotations and type arguments detected by pyright. (#5061) Co-authored-by: Eric Traut --- stdlib/tarfile.pyi | 10 +++++++--- stubs/attrs/attr/validators.pyi | 4 ++-- stubs/mock/mock.pyi | 2 +- stubs/python-dateutil/dateutil/_common.pyi | 2 +- stubs/python-dateutil/dateutil/relativedelta.pyi | 2 +- stubs/retry/retry/api.pyi | 2 +- stubs/waitress/waitress/adjustments.pyi | 4 ++-- stubs/xxhash/xxhash.pyi | 2 +- 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 5357b087a..0244359f3 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -322,9 +322,13 @@ class TarInfo: def linkpath(self, linkname: str) -> None: ... def get_info(self) -> Mapping[str, Union[str, int, bytes, Mapping[str, str]]]: ... def tobuf(self, format: Optional[int] = ..., encoding: Optional[str] = ..., errors: str = ...) -> bytes: ... - def create_ustar_header(self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str, errors: str): ... - def create_gnu_header(self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str, errors: str): ... - def create_pax_header(self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str): ... + def create_ustar_header( + self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str, errors: str + ) -> bytes: ... + def create_gnu_header( + self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str, errors: str + ) -> bytes: ... + def create_pax_header(self, info: Mapping[str, Union[str, int, bytes, Mapping[str, str]]], encoding: str) -> bytes: ... @classmethod def create_pax_global_header(cls, pax_headers: Mapping[str, str]) -> bytes: ... def isfile(self) -> bool: ... diff --git a/stubs/attrs/attr/validators.pyi b/stubs/attrs/attr/validators.pyi index 49a7cbad5..4b235fcb0 100644 --- a/stubs/attrs/attr/validators.pyi +++ b/stubs/attrs/attr/validators.pyi @@ -21,10 +21,10 @@ _T = TypeVar("_T") _T1 = TypeVar("_T1") _T2 = TypeVar("_T2") _T3 = TypeVar("_T3") -_I = TypeVar("_I", bound=Iterable) +_I = TypeVar("_I", bound=Iterable[Any]) _K = TypeVar("_K") _V = TypeVar("_V") -_M = TypeVar("_M", bound=Mapping) +_M = TypeVar("_M", bound=Mapping[Any, Any]) # To be more precise on instance_of use some overloads. # If there are more than 3 items in the tuple then we fall back to Any diff --git a/stubs/mock/mock.pyi b/stubs/mock/mock.pyi index 013a22a2d..4e02c5f06 100644 --- a/stubs/mock/mock.pyi +++ b/stubs/mock/mock.pyi @@ -390,7 +390,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/stubs/python-dateutil/dateutil/_common.pyi b/stubs/python-dateutil/dateutil/_common.pyi index 0a6d8e008..c8326dbb9 100644 --- a/stubs/python-dateutil/dateutil/_common.pyi +++ b/stubs/python-dateutil/dateutil/_common.pyi @@ -5,7 +5,7 @@ _T = TypeVar("_T") class weekday(object): def __init__(self, weekday: int, n: Optional[int] = ...) -> None: ... def __call__(self: _T, n: int) -> _T: ... - def __eq__(self, other) -> bool: ... + def __eq__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __hash__(self) -> int: ... weekday: int diff --git a/stubs/python-dateutil/dateutil/relativedelta.pyi b/stubs/python-dateutil/dateutil/relativedelta.pyi index a0de3e7fd..d8cfe61c3 100644 --- a/stubs/python-dateutil/dateutil/relativedelta.pyi +++ b/stubs/python-dateutil/dateutil/relativedelta.pyi @@ -88,7 +88,7 @@ class relativedelta(object): def __nonzero__(self) -> bool: ... def __mul__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... def __rmul__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... - def __eq__(self, other) -> bool: ... + def __eq__(self, other: object) -> bool: ... def __ne__(self, other: object) -> bool: ... def __div__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... def __truediv__(self: _SelfT, other: SupportsFloat) -> _SelfT: ... diff --git a/stubs/retry/retry/api.pyi b/stubs/retry/retry/api.pyi index 37fa2009d..88f274b9d 100644 --- a/stubs/retry/retry/api.pyi +++ b/stubs/retry/retry/api.pyi @@ -25,4 +25,4 @@ def retry( backoff: float = ..., jitter: Union[Tuple[float, float], float] = ..., logger: Optional[Logger] = ..., -) -> _Decorator: ... +) -> _Decorator[_T]: ... diff --git a/stubs/waitress/waitress/adjustments.pyi b/stubs/waitress/waitress/adjustments.pyi index 54b15ee26..0343887a4 100644 --- a/stubs/waitress/waitress/adjustments.pyi +++ b/stubs/waitress/waitress/adjustments.pyi @@ -4,8 +4,8 @@ from typing import Any, Dict, FrozenSet, Iterable, List, Optional, Sequence, Set from .compat import HAS_IPV6 as HAS_IPV6, PY2 as PY2, WIN as WIN, string_types as string_types from .proxy_headers import PROXY_HEADERS as PROXY_HEADERS -truthy: FrozenSet -KNOWN_PROXY_HEADERS: FrozenSet +truthy: FrozenSet[Any] +KNOWN_PROXY_HEADERS: FrozenSet[Any] def asbool(s: Optional[Union[bool, str, int]]) -> bool: ... def asoctal(s: str) -> int: ... diff --git a/stubs/xxhash/xxhash.pyi b/stubs/xxhash/xxhash.pyi index dc31adb6e..97b1a2d0e 100644 --- a/stubs/xxhash/xxhash.pyi +++ b/stubs/xxhash/xxhash.pyi @@ -10,7 +10,7 @@ VERSION: str XXHASH_VERSION: str class _IntDigestHash(_Hash): - def __init__(self, __string: ReadableBuffer = ...): ... + def __init__(self, __string: ReadableBuffer = ...) -> None: ... def intdigest(self) -> int: ... # python-xxhash v2.0.0 does not support the string or usedforsecurity kwargs