Skip to content

Commit f74b24b

Browse files
Add Python 3.15 calendar datetime and difflib updates (#15729)
1 parent 1593fa3 commit f74b24b

4 files changed

Lines changed: 74 additions & 31 deletions

File tree

stdlib/@tests/stubtest_allowlists/py315.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ binascii.b2a_base32
112112
binascii.b2a_base64
113113
binascii.b2a_base85
114114
binascii.unhexlify
115-
calendar.HTMLCalendar.formatmonthpage
116-
calendar.__all__
117-
calendar.standalone_month_abbr
118-
calendar.standalone_month_name
119115
codecs.backslashreplace_errors
120116
codecs.ignore_errors
121117
codecs.namereplace_errors
@@ -140,13 +136,6 @@ ctypes.SetPointerType
140136
dataclasses._MISSING_TYPE
141137
dataclasses.MISSING
142138
dataclasses.field
143-
datetime.date.fromisoformat
144-
datetime.date.strptime
145-
datetime.datetime.fromisoformat
146-
datetime.datetime.strptime
147-
datetime.time.fromisoformat
148-
datetime.time.strptime
149-
difflib.unified_diff
150139
doctest.DocTestRunner.report_skip
151140
enum.__all__
152141
enum.auto.__init__

stdlib/calendar.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ if sys.version_info >= (3, 12):
5757
"NOVEMBER",
5858
"DECEMBER",
5959
]
60+
if sys.version_info >= (3, 15):
61+
__all__ += ["standalone_month_name", "standalone_month_abbr"]
6062

6163
_LocaleType: TypeAlias = tuple[str | None, str | None]
6264

@@ -127,6 +129,11 @@ class HTMLCalendar(Calendar):
127129
def formatweekheader(self) -> str: ...
128130
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = True) -> str: ...
129131
def formatmonth(self, theyear: int, themonth: int, withyear: bool = True) -> str: ...
132+
if sys.version_info >= (3, 15):
133+
def formatmonthpage(
134+
self, theyear: int, themonth: int, width: int = 3, css: str | None = "calendar.css", encoding: str | None = None
135+
) -> bytes: ...
136+
130137
def formatyear(self, theyear: int, width: int = 3) -> str: ...
131138
def formatyearpage(
132139
self, theyear: int, width: int = 3, css: str | None = "calendar.css", encoding: str | None = None
@@ -212,3 +219,7 @@ else:
212219
SUNDAY: Final = 6
213220

214221
EPOCH: Final = 1970
222+
223+
if sys.version_info >= (3, 15):
224+
standalone_month_name: Sequence[str]
225+
standalone_month_abbr: Sequence[str]

stdlib/datetime.pyi

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ class date:
6363
def today(cls) -> Self: ...
6464
@classmethod
6565
def fromordinal(cls, n: int, /) -> Self: ...
66-
@classmethod
67-
def fromisoformat(cls, date_string: str, /) -> Self: ...
66+
if sys.version_info >= (3, 15):
67+
@classmethod
68+
def fromisoformat(cls, string: str, /) -> Self: ...
69+
else:
70+
@classmethod
71+
def fromisoformat(cls, date_string: str, /) -> Self: ...
72+
6873
@classmethod
6974
def fromisocalendar(cls, year: int, week: int, day: int) -> Self: ...
7075
@property
@@ -76,8 +81,12 @@ class date:
7681
def ctime(self) -> str: ...
7782

7883
if sys.version_info >= (3, 14):
79-
@classmethod
80-
def strptime(cls, date_string: str, format: str, /) -> Self: ...
84+
if sys.version_info >= (3, 15):
85+
@classmethod
86+
def strptime(cls, string: str, format: str, /) -> Self: ...
87+
else:
88+
@classmethod
89+
def strptime(cls, date_string: str, format: str, /) -> Self: ...
8190

8291
# On <3.12, the name of the parameter in the pure-Python implementation
8392
# didn't match the name in the C implementation,
@@ -147,12 +156,20 @@ class time:
147156
def __eq__(self, value: object, /) -> bool: ...
148157
def __hash__(self) -> int: ...
149158
def isoformat(self, timespec: str = "auto") -> str: ...
150-
@classmethod
151-
def fromisoformat(cls, time_string: str, /) -> Self: ...
159+
if sys.version_info >= (3, 15):
160+
@classmethod
161+
def fromisoformat(cls, string: str, /) -> Self: ...
162+
else:
163+
@classmethod
164+
def fromisoformat(cls, time_string: str, /) -> Self: ...
152165

153166
if sys.version_info >= (3, 14):
154-
@classmethod
155-
def strptime(cls, date_string: str, format: str, /) -> Self: ...
167+
if sys.version_info >= (3, 15):
168+
@classmethod
169+
def strptime(cls, string: str, format: str, /) -> Self: ...
170+
else:
171+
@classmethod
172+
def strptime(cls, date_string: str, format: str, /) -> Self: ...
156173

157174
# On <3.12, the name of the parameter in the pure-Python implementation
158175
# didn't match the name in the C implementation,
@@ -291,6 +308,10 @@ class datetime(date):
291308
def utcnow(cls) -> Self: ...
292309
@classmethod
293310
def combine(cls, date: _Date, time: _Time, tzinfo: _TzInfo | None = ...) -> Self: ...
311+
if sys.version_info >= (3, 15):
312+
@classmethod
313+
def fromisoformat(cls, string: str, /) -> Self: ...
314+
294315
def timestamp(self) -> float: ...
295316
def utctimetuple(self) -> struct_time: ...
296317
def date(self) -> _Date: ...
@@ -327,8 +348,13 @@ class datetime(date):
327348
) -> Self: ...
328349
def astimezone(self, tz: _TzInfo | None = None) -> Self: ...
329350
def isoformat(self, sep: str = "T", timespec: str = "auto") -> str: ...
330-
@classmethod
331-
def strptime(cls, date_string: str, format: str, /) -> Self: ...
351+
if sys.version_info >= (3, 15):
352+
@classmethod
353+
def strptime(cls, string: str, format: str, /) -> Self: ...
354+
else:
355+
@classmethod
356+
def strptime(cls, date_string: str, format: str, /) -> Self: ...
357+
332358
def utcoffset(self) -> timedelta | None: ...
333359
def tzname(self) -> str | None: ...
334360
def dst(self) -> timedelta | None: ...

stdlib/difflib.pyi

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,33 @@ else:
6969
def IS_LINE_JUNK(line: str, pat: Callable[[str], re.Match[str] | None] = ...) -> bool: ...
7070

7171
def IS_CHARACTER_JUNK(ch: str, ws: str = " \t") -> bool: ... # ws is undocumented
72-
def unified_diff(
73-
a: Sequence[str],
74-
b: Sequence[str],
75-
fromfile: str = "",
76-
tofile: str = "",
77-
fromfiledate: str = "",
78-
tofiledate: str = "",
79-
n: int = 3,
80-
lineterm: str = "\n",
81-
) -> Iterator[str]: ...
72+
73+
if sys.version_info >= (3, 15):
74+
def unified_diff(
75+
a: Sequence[str],
76+
b: Sequence[str],
77+
fromfile: str = "",
78+
tofile: str = "",
79+
fromfiledate: str = "",
80+
tofiledate: str = "",
81+
n: int = 3,
82+
lineterm: str = "\n",
83+
*,
84+
color: bool = False,
85+
) -> Iterator[str]: ...
86+
87+
else:
88+
def unified_diff(
89+
a: Sequence[str],
90+
b: Sequence[str],
91+
fromfile: str = "",
92+
tofile: str = "",
93+
fromfiledate: str = "",
94+
tofiledate: str = "",
95+
n: int = 3,
96+
lineterm: str = "\n",
97+
) -> Iterator[str]: ...
98+
8299
def context_diff(
83100
a: Sequence[str],
84101
b: Sequence[str],

0 commit comments

Comments
 (0)