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
82 changes: 58 additions & 24 deletions stdlib/datetime.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ class date:
def isoformat(self) -> str: ...
def timetuple(self) -> struct_time: ...
def toordinal(self) -> int: ...
def replace(self, year: int = ..., month: int = ..., day: int = ...) -> date: ...
if sys.version_info >= (3, 6):
def replace(self: Self, year: int = ..., month: int = ..., day: int = ...) -> Self: ...
else:
# Prior to Python 3.6, the `replace` method always returned `date`, even in subclasses
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: ...
Expand Down Expand Up @@ -139,16 +144,29 @@ class time:
def utcoffset(self) -> timedelta | None: ...
def tzname(self) -> str | None: ...
def dst(self) -> timedelta | None: ...
def replace(
self,
hour: int = ...,
minute: int = ...,
second: int = ...,
microsecond: int = ...,
tzinfo: _tzinfo | None = ...,
*,
fold: int = ...,
) -> time: ...
if sys.version_info >= (3, 6):
def replace(
self: Self,
hour: int = ...,
minute: int = ...,
second: int = ...,
microsecond: int = ...,
tzinfo: _tzinfo | None = ...,
*,
fold: int = ...,
) -> Self: ...
else:
# Prior to Python 3.6, the `replace` method always returned `time`, even in subclasses
def replace(
self,
hour: int = ...,
minute: int = ...,
second: int = ...,
microsecond: int = ...,
tzinfo: _tzinfo | None = ...,
*,
fold: int = ...,
) -> time: ...

_date = date
_time = time
Expand Down Expand Up @@ -260,19 +278,35 @@ class datetime(date):
def date(self) -> _date: ...
def time(self) -> _time: ...
def timetz(self) -> _time: ...
def replace(
self,
year: int = ...,
month: int = ...,
day: int = ...,
hour: int = ...,
minute: int = ...,
second: int = ...,
microsecond: int = ...,
tzinfo: _tzinfo | None = ...,
*,
fold: int = ...,
) -> datetime: ...
if sys.version_info >= (3, 6):
def replace(
self: Self,
year: int = ...,
month: int = ...,
day: int = ...,
hour: int = ...,
minute: int = ...,
second: int = ...,
microsecond: int = ...,
tzinfo: _tzinfo | None = ...,
*,
fold: int = ...,
) -> Self: ...
else:
# Prior to Python 3.6, the `replace` method always returned `datetime`, even in subclasses
def replace(
self,
year: int = ...,
month: int = ...,
day: int = ...,
hour: int = ...,
minute: int = ...,
second: int = ...,
microsecond: int = ...,
tzinfo: _tzinfo | None = ...,
*,
fold: int = ...,
) -> datetime: ...
if sys.version_info >= (3, 8):
def astimezone(self: Self, tz: _tzinfo | None = ...) -> Self: ...
else:
Expand Down