Skip to content

Commit 601587e

Browse files
changed overload order for date.__sub__ and datetime.__sub__ (#10999)
1 parent df409a2 commit 601587e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

stdlib/datetime.pyi

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import sys
22
from abc import abstractmethod
33
from time import struct_time
4-
from typing import ClassVar, Literal, NamedTuple, NoReturn, SupportsIndex, TypeVar, final, overload
4+
from typing import ClassVar, Literal, NamedTuple, NoReturn, SupportsIndex, final, overload
55
from typing_extensions import Self, TypeAlias, deprecated
66

77
if sys.version_info >= (3, 11):
88
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR", "UTC")
99
elif sys.version_info >= (3, 9):
1010
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR")
1111

12-
_D = TypeVar("_D", bound=date)
13-
1412
MINYEAR: Literal[1]
1513
MAXYEAR: Literal[9999]
1614

@@ -90,11 +88,11 @@ class date:
9088
def __add__(self, __value: timedelta) -> Self: ...
9189
def __radd__(self, __value: timedelta) -> Self: ...
9290
@overload
93-
def __sub__(self, __value: timedelta) -> Self: ...
94-
@overload
9591
def __sub__(self, __value: datetime) -> NoReturn: ...
9692
@overload
97-
def __sub__(self: _D, __value: _D) -> timedelta: ...
93+
def __sub__(self, __value: Self) -> timedelta: ...
94+
@overload
95+
def __sub__(self, __value: timedelta) -> Self: ...
9896
def __hash__(self) -> int: ...
9997
def weekday(self) -> int: ...
10098
def isoweekday(self) -> int: ...
@@ -292,6 +290,6 @@ class datetime(date):
292290
def __eq__(self, __value: object) -> bool: ...
293291
def __hash__(self) -> int: ...
294292
@overload # type: ignore[override]
295-
def __sub__(self, __value: timedelta) -> Self: ...
293+
def __sub__(self, __value: Self) -> timedelta: ...
296294
@overload
297-
def __sub__(self: _D, __value: _D) -> timedelta: ...
295+
def __sub__(self, __value: timedelta) -> Self: ...

0 commit comments

Comments
 (0)