datetime: various parameters can now safely be passed as keyword arguments on 3.12+ (#9415)

This commit is contained in:
Alex Waygood
2022-12-27 14:35:29 +00:00
committed by GitHub
parent d6237d09c7
commit 116229d0ac

View File

@@ -70,7 +70,14 @@ class date:
@property
def day(self) -> int: ...
def ctime(self) -> str: ...
def strftime(self, __format: str) -> str: ...
# On <3.12, the name of the parameter in the pure-Python implementation
# didn't match the name in the C implementation,
# meaning it is only *safe* to pass it as a keyword argument on 3.12+
if sys.version_info >= (3, 12):
def strftime(self, format: str) -> str: ...
else:
def strftime(self, __format: str) -> str: ...
def __format__(self, __fmt: str) -> str: ...
def isoformat(self) -> str: ...
def timetuple(self) -> struct_time: ...
@@ -140,7 +147,14 @@ class time:
def isoformat(self, timespec: str = ...) -> str: ...
@classmethod
def fromisoformat(cls: type[Self], __time_string: str) -> Self: ...
def strftime(self, __format: str) -> str: ...
# On <3.12, the name of the parameter in the pure-Python implementation
# didn't match the name in the C implementation,
# meaning it is only *safe* to pass it as a keyword argument on 3.12+
if sys.version_info >= (3, 12):
def strftime(self, format: str) -> str: ...
else:
def strftime(self, __format: str) -> str: ...
def __format__(self, __fmt: str) -> str: ...
def utcoffset(self) -> timedelta | None: ...
def tzname(self) -> str | None: ...
@@ -233,11 +247,16 @@ 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[Self], __timestamp: float, tz: _TzInfo | None = ...) -> Self: ...
# On <3.12, the name of the first parameter in the pure-Python implementation
# didn't match the name in the C implementation,
# meaning it is only *safe* to pass it as a keyword argument on 3.12+
if sys.version_info >= (3, 12):
@classmethod
def fromtimestamp(cls: type[Self], timestamp: float, tz: _TzInfo | None = ...) -> Self: ...
else:
@classmethod
def fromtimestamp(cls: type[Self], __timestamp: float, tz: _TzInfo | None = ...) -> Self: ...
@classmethod
def utcfromtimestamp(cls: type[Self], __t: float) -> Self: ...
if sys.version_info >= (3, 8):