changed overload order for date.__sub__ and datetime.__sub__ (#10999)

This commit is contained in:
Randolf Scholz
2024-02-19 13:11:29 +01:00
committed by GitHub
parent df409a2fb5
commit 601587e71d

View File

@@ -1,7 +1,7 @@
import sys
from abc import abstractmethod
from time import struct_time
from typing import ClassVar, Literal, NamedTuple, NoReturn, SupportsIndex, TypeVar, final, overload
from typing import ClassVar, Literal, NamedTuple, NoReturn, SupportsIndex, final, overload
from typing_extensions import Self, TypeAlias, deprecated
if sys.version_info >= (3, 11):
@@ -9,8 +9,6 @@ if sys.version_info >= (3, 11):
elif sys.version_info >= (3, 9):
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR")
_D = TypeVar("_D", bound=date)
MINYEAR: Literal[1]
MAXYEAR: Literal[9999]
@@ -90,11 +88,11 @@ class date:
def __add__(self, __value: timedelta) -> Self: ...
def __radd__(self, __value: timedelta) -> Self: ...
@overload
def __sub__(self, __value: timedelta) -> Self: ...
@overload
def __sub__(self, __value: datetime) -> NoReturn: ...
@overload
def __sub__(self: _D, __value: _D) -> timedelta: ...
def __sub__(self, __value: Self) -> timedelta: ...
@overload
def __sub__(self, __value: timedelta) -> Self: ...
def __hash__(self) -> int: ...
def weekday(self) -> int: ...
def isoweekday(self) -> int: ...
@@ -292,6 +290,6 @@ class datetime(date):
def __eq__(self, __value: object) -> bool: ...
def __hash__(self) -> int: ...
@overload # type: ignore[override]
def __sub__(self, __value: timedelta) -> Self: ...
def __sub__(self, __value: Self) -> timedelta: ...
@overload
def __sub__(self: _D, __value: _D) -> timedelta: ...
def __sub__(self, __value: timedelta) -> Self: ...