Skip to content
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
117 changes: 60 additions & 57 deletions stdlib/datetime.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ MINYEAR: int
MAXYEAR: int

class tzinfo:
def tzname(self, dt: datetime | None) -> str | None: ...
def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
def dst(self, dt: datetime | None) -> timedelta | None: ...
def fromutc(self, dt: datetime) -> datetime: ...
def tzname(self, __dt: datetime | None) -> str | None: ...
def utcoffset(self, __dt: datetime | None) -> timedelta | None: ...
def dst(self, __dt: datetime | None) -> timedelta | None: ...
def fromutc(self, __dt: datetime) -> datetime: ...

# Alias required to avoid name conflicts with date(time).tzinfo.
_tzinfo = tzinfo
Expand Down Expand Up @@ -42,10 +42,10 @@ class date:
@classmethod
def today(cls: Type[_S]) -> _S: ...
@classmethod
def fromordinal(cls: Type[_S], n: int) -> _S: ...
def fromordinal(cls: Type[_S], __n: int) -> _S: ...
if sys.version_info >= (3, 7):
@classmethod
def fromisoformat(cls: Type[_S], date_string: str) -> _S: ...
def fromisoformat(cls: Type[_S], __date_string: str) -> _S: ...
if sys.version_info >= (3, 8):
@classmethod
def fromisocalendar(cls: Type[_S], year: int, week: int, day: int) -> _S: ...
Expand All @@ -57,34 +57,34 @@ class date:
def day(self) -> int: ...
def ctime(self) -> str: ...
def strftime(self, fmt: str) -> str: ...
def __format__(self, fmt: str) -> str: ...
def __format__(self, __fmt: str) -> str: ...
def isoformat(self) -> str: ...
def timetuple(self) -> struct_time: ...
def toordinal(self) -> int: ...
def replace(self, year: int = ..., month: int = ..., day: int = ...) -> date: ...
def __le__(self, other: date) -> bool: ...
def __lt__(self, other: date) -> bool: ...
def __ge__(self, other: date) -> bool: ...
def __gt__(self, other: date) -> bool: ...
def __le__(self, __other: date) -> bool: ...
def __lt__(self, __other: date) -> bool: ...
def __ge__(self, __other: date) -> bool: ...
def __gt__(self, __other: date) -> bool: ...
if sys.version_info >= (3, 8):
def __add__(self: _S, other: timedelta) -> _S: ...
def __radd__(self: _S, other: timedelta) -> _S: ...
def __add__(self: _S, __other: timedelta) -> _S: ...
def __radd__(self: _S, __other: timedelta) -> _S: ...
@overload
def __sub__(self: _D, other: timedelta) -> _D: ...
def __sub__(self: _D, __other: timedelta) -> _D: ...
@overload
def __sub__(self, other: datetime) -> NoReturn: ...
def __sub__(self, __other: datetime) -> NoReturn: ...
@overload
def __sub__(self: _D, other: _D) -> timedelta: ...
def __sub__(self: _D, __other: _D) -> timedelta: ...
else:
# Prior to Python 3.8, arithmetic operations always returned `date`, even in subclasses
def __add__(self, other: timedelta) -> date: ...
def __radd__(self, other: timedelta) -> date: ...
def __add__(self, __other: timedelta) -> date: ...
def __radd__(self, __other: timedelta) -> date: ...
@overload
def __sub__(self, other: timedelta) -> date: ...
def __sub__(self, __other: timedelta) -> date: ...
@overload
def __sub__(self, other: datetime) -> NoReturn: ...
def __sub__(self, __other: datetime) -> NoReturn: ...
@overload
def __sub__(self, other: date) -> timedelta: ...
def __sub__(self, __other: date) -> timedelta: ...
def __hash__(self) -> int: ...
def weekday(self) -> int: ...
def isoweekday(self) -> int: ...
Expand Down Expand Up @@ -119,17 +119,17 @@ class time:
def tzinfo(self) -> _tzinfo | None: ...
@property
def fold(self) -> int: ...
def __le__(self, other: time) -> bool: ...
def __lt__(self, other: time) -> bool: ...
def __ge__(self, other: time) -> bool: ...
def __gt__(self, other: time) -> bool: ...
def __le__(self, __other: time) -> bool: ...
def __lt__(self, __other: time) -> bool: ...
def __ge__(self, __other: time) -> bool: ...
def __gt__(self, __other: time) -> bool: ...
def __hash__(self) -> int: ...
def isoformat(self, timespec: str = ...) -> str: ...
if sys.version_info >= (3, 7):
@classmethod
def fromisoformat(cls: Type[_S], time_string: str) -> _S: ...
def fromisoformat(cls: Type[_S], __time_string: str) -> _S: ...
def strftime(self, fmt: str) -> str: ...
def __format__(self, fmt: str) -> str: ...
def __format__(self, __fmt: str) -> str: ...
def utcoffset(self) -> timedelta | None: ...
def tzname(self) -> str | None: ...
def dst(self) -> timedelta | None: ...
Expand Down Expand Up @@ -168,29 +168,29 @@ class timedelta(SupportsAbs[timedelta]):
@property
def microseconds(self) -> int: ...
def total_seconds(self) -> float: ...
def __add__(self, other: timedelta) -> timedelta: ...
def __radd__(self, other: timedelta) -> timedelta: ...
def __sub__(self, other: timedelta) -> timedelta: ...
def __rsub__(self, other: timedelta) -> timedelta: ...
def __add__(self, __other: timedelta) -> timedelta: ...
def __radd__(self, __other: timedelta) -> timedelta: ...
def __sub__(self, __other: timedelta) -> timedelta: ...
def __rsub__(self, __other: timedelta) -> timedelta: ...
def __neg__(self) -> timedelta: ...
def __pos__(self) -> timedelta: ...
def __abs__(self) -> timedelta: ...
def __mul__(self, other: float) -> timedelta: ...
def __rmul__(self, other: float) -> timedelta: ...
def __mul__(self, __other: float) -> timedelta: ...
def __rmul__(self, __other: float) -> timedelta: ...
@overload
def __floordiv__(self, other: timedelta) -> int: ...
def __floordiv__(self, __other: timedelta) -> int: ...
@overload
def __floordiv__(self, other: int) -> timedelta: ...
def __floordiv__(self, __other: int) -> timedelta: ...
@overload
def __truediv__(self, other: timedelta) -> float: ...
def __truediv__(self, __other: timedelta) -> float: ...
@overload
def __truediv__(self, other: float) -> timedelta: ...
def __mod__(self, other: timedelta) -> timedelta: ...
def __divmod__(self, other: timedelta) -> tuple[int, timedelta]: ...
def __le__(self, other: timedelta) -> bool: ...
def __lt__(self, other: timedelta) -> bool: ...
def __ge__(self, other: timedelta) -> bool: ...
def __gt__(self, other: timedelta) -> bool: ...
def __truediv__(self, __other: float) -> timedelta: ...
def __mod__(self, __other: timedelta) -> timedelta: ...
def __divmod__(self, __other: timedelta) -> tuple[int, timedelta]: ...
def __le__(self, __other: timedelta) -> bool: ...
def __lt__(self, __other: timedelta) -> bool: ...
def __ge__(self, __other: timedelta) -> bool: ...
def __gt__(self, __other: timedelta) -> bool: ...
def __bool__(self) -> bool: ...
def __hash__(self) -> int: ...

Expand Down Expand Up @@ -223,10 +223,13 @@ class datetime(date):
def tzinfo(self) -> _tzinfo | None: ...
@property
def fold(self) -> int: ...
# The first parameter in `fromtimestamp` is actually positional-or-keyword,
# but it is named "timestamp" in the C implementation and "t" in the Python implementation,
# so it is only truly *safe* to pass it as a positional argument.
@classmethod
def fromtimestamp(cls: Type[_S], t: float, tz: _tzinfo | None = ...) -> _S: ...
def fromtimestamp(cls: Type[_S], __timestamp: float, tz: _tzinfo | None = ...) -> _S: ...
@classmethod
def utcfromtimestamp(cls: Type[_S], t: float) -> _S: ...
def utcfromtimestamp(cls: Type[_S], __t: float) -> _S: ...
if sys.version_info >= (3, 8):
@classmethod
def now(cls: Type[_S], tz: _tzinfo | None = ...) -> _S: ...
Expand All @@ -243,7 +246,7 @@ class datetime(date):
def combine(cls, date: _date, time: _time, tzinfo: _tzinfo | None = ...) -> datetime: ...
if sys.version_info >= (3, 7):
@classmethod
def fromisoformat(cls: Type[_S], date_string: str) -> _S: ...
def fromisoformat(cls: Type[_S], __date_string: str) -> _S: ...
def timestamp(self) -> float: ...
def utctimetuple(self) -> struct_time: ...
def date(self) -> _date: ...
Expand All @@ -269,27 +272,27 @@ class datetime(date):
def ctime(self) -> str: ...
def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ...
@classmethod
def strptime(cls, date_string: str, format: str) -> datetime: ...
def strptime(cls, __date_string: str, __format: str) -> datetime: ...
def utcoffset(self) -> timedelta | None: ...
def tzname(self) -> str | None: ...
def dst(self) -> timedelta | None: ...
def __le__(self, other: datetime) -> bool: ... # type: ignore
def __lt__(self, other: datetime) -> bool: ... # type: ignore
def __ge__(self, other: datetime) -> bool: ... # type: ignore
def __gt__(self, other: datetime) -> bool: ... # type: ignore
def __le__(self, __other: datetime) -> bool: ... # type: ignore
def __lt__(self, __other: datetime) -> bool: ... # type: ignore
def __ge__(self, __other: datetime) -> bool: ... # type: ignore
def __gt__(self, __other: datetime) -> bool: ... # type: ignore
if sys.version_info >= (3, 8):
@overload # type: ignore[override]
def __sub__(self: _D, other: timedelta) -> _D: ...
def __sub__(self: _D, __other: timedelta) -> _D: ...
@overload
def __sub__(self: _D, other: _D) -> timedelta: ...
def __sub__(self: _D, __other: _D) -> timedelta: ...
else:
# Prior to Python 3.8, arithmetic operations always returned `datetime`, even in subclasses
def __add__(self, other: timedelta) -> datetime: ...
def __radd__(self, other: timedelta) -> datetime: ...
def __add__(self, __other: timedelta) -> datetime: ...
def __radd__(self, __other: timedelta) -> datetime: ...
@overload # type: ignore[override]
def __sub__(self, other: datetime) -> timedelta: ...
def __sub__(self, __other: datetime) -> timedelta: ...
@overload
def __sub__(self, other: timedelta) -> datetime: ...
def __sub__(self, __other: timedelta) -> datetime: ...
if sys.version_info >= (3, 9):
def isocalendar(self) -> _IsoCalendarDate: ...
else:
Expand Down