Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions stdlib/datetime.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
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):
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR", "UTC")
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]

Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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: ...