From 8ce64aca6e84860ffbd2605f7cb52e97c8c10771 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Wed, 5 Jan 2022 10:58:17 -0600 Subject: [PATCH] [0.931 backport] Fix __reduce__ regression (#11866) Co-authored-by: hauntsaninja <> --- mypy/typeshed/stdlib/builtins.pyi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi index 71efda9b979a..1b2d3db12c3f 100644 --- a/mypy/typeshed/stdlib/builtins.pyi +++ b/mypy/typeshed/stdlib/builtins.pyi @@ -100,11 +100,13 @@ class object: def __getattribute__(self, __name: str) -> Any: ... def __delattr__(self, __name: str) -> None: ... def __sizeof__(self) -> int: ... - def __reduce__(self) -> str | Tuple[object, ...]: ... + # return type of pickle methods is rather hard to express in the current type system + # see #6661 and https://docs.python.org/3/library/pickle.html#object.__reduce__ + def __reduce__(self) -> str | Tuple[Any, ...]: ... if sys.version_info >= (3, 8): - def __reduce_ex__(self, __protocol: SupportsIndex) -> str | Tuple[object, ...]: ... + def __reduce_ex__(self, __protocol: SupportsIndex) -> str | Tuple[Any, ...]: ... else: - def __reduce_ex__(self, __protocol: int) -> str | Tuple[object, ...]: ... + def __reduce_ex__(self, __protocol: int) -> str | Tuple[Any, ...]: ... def __dir__(self) -> Iterable[str]: ... def __init_subclass__(cls) -> None: ...