From f90424014bf9cae28af38cfda7ddd20bb8f78f38 Mon Sep 17 00:00:00 2001 From: Max Muoto Date: Sat, 10 May 2025 14:02:43 -0500 Subject: [PATCH] Add strptime for `datetime.time` and `datetime.date` (3.14) (#13991) --- stdlib/@tests/stubtest_allowlists/py314.txt | 2 -- stdlib/datetime.pyi | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py314.txt b/stdlib/@tests/stubtest_allowlists/py314.txt index aedbbcde0..bfbf9cd9f 100644 --- a/stdlib/@tests/stubtest_allowlists/py314.txt +++ b/stdlib/@tests/stubtest_allowlists/py314.txt @@ -364,8 +364,6 @@ dataclasses.Field.__init__ dataclasses.Field.doc dataclasses.field dataclasses.make_dataclass -datetime.date.strptime -datetime.time.strptime decimal.Decimal.from_number decimal.DecimalTuple.__annotate_func__ decimal.DecimalTuple.__annotations_cache__ diff --git a/stdlib/datetime.pyi b/stdlib/datetime.pyi index 72fb5fceb..37d6a06df 100644 --- a/stdlib/datetime.pyi +++ b/stdlib/datetime.pyi @@ -73,6 +73,11 @@ class date: @property def day(self) -> int: ... def ctime(self) -> str: ... + + if sys.version_info >= (3, 14): + @classmethod + def strptime(cls, date_string: str, format: str, /) -> Self: ... + # 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+ @@ -142,6 +147,11 @@ class time: def isoformat(self, timespec: str = ...) -> str: ... @classmethod def fromisoformat(cls, time_string: str, /) -> Self: ... + + if sys.version_info >= (3, 14): + @classmethod + def strptime(cls, date_string: str, format: str, /) -> Self: ... + # 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+