diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 12e53921e946..6fd241930a0c 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -1,7 +1,8 @@ import sys +from _typeshed import Self from time import struct_time from typing import ClassVar, NamedTuple, SupportsAbs, Type, TypeVar, overload -from typing_extensions import final +from typing_extensions import SupportsIndex, final _S = TypeVar("_S") @@ -13,6 +14,7 @@ class tzinfo: def utcoffset(self, dt: datetime | None) -> timedelta | None: ... def dst(self, dt: datetime | None) -> timedelta | None: ... def fromutc(self, dt: datetime) -> datetime: ... + def __reduce__(self: Self) -> tuple[Type[Self], tuple[Self]]: ... # Alias required to avoid name conflicts with date(time).tzinfo. _tzinfo = tzinfo @@ -75,6 +77,11 @@ class date: def __sub__(self, other: timedelta) -> date: ... @overload def __sub__(self, other: date) -> timedelta: ... + def __reduce__(self: Self) -> tuple[Type[Self], tuple[bytes]]: ... + if sys.version_info >= (3, 8): + def __reduce_ex__(self: Self, __protocol: SupportsIndex) -> tuple[Type[Self], tuple[bytes]]: ... + else: + def __reduce_ex__(self: Self, __protocol: int) -> tuple[Type[Self], tuple[bytes]]: ... def __hash__(self) -> int: ... def weekday(self) -> int: ... def isoweekday(self) -> int: ... @@ -114,6 +121,11 @@ class time: def __ge__(self, other: time) -> bool: ... def __gt__(self, other: time) -> bool: ... def __hash__(self) -> int: ... + def __reduce__(self: Self) -> tuple[Type[Self], tuple[bytes]]: ... + if sys.version_info >= (3, 8): + def __reduce_ex__(self: Self, __protocol: SupportsIndex) -> tuple[Type[Self], tuple[bytes]]: ... + else: + def __reduce_ex__(self: Self, __protocol: int) -> tuple[Type[Self], tuple[bytes]]: ... def isoformat(self, timespec: str = ...) -> str: ... if sys.version_info >= (3, 7): @classmethod @@ -183,6 +195,7 @@ class timedelta(SupportsAbs[timedelta]): def __gt__(self, other: timedelta) -> bool: ... def __bool__(self) -> bool: ... def __hash__(self) -> int: ... + def __reduce__(self: Self) -> tuple[Type[Self], tuple[int, int, int]]: ... class datetime(date): min: ClassVar[datetime]