Skip to content

Commit ebaa73a

Browse files
authored
Initial support for Python 3.15.0a8 (#21255)
Some minor changes to be able to compile mypy with mypyc on Python 3.15.0a8. - Update `typing-extensions` to `>=4.14.0` for Python `>=3.15` due to the removal of `typing.no_type_check_decorator` python/cpython#133601 https://docs.python.org/3/library/typing.html#typing.no_type_check_decorator https://github.com/python/typing_extensions/blob/4.14.0/CHANGELOG.md - `TypeAliasType.__qualname__` was added in python/cpython#139817 - Some new FutureWarnings for b64_decode python/cpython#125346 python/cpython#141128
1 parent 958c4ba commit ebaa73a

File tree

7 files changed

+36
-8
lines changed

7 files changed

+36
-8
lines changed

mypy-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml
22
# and the pins in setup.py
3-
typing_extensions>=4.6.0
3+
typing_extensions>=4.6.0; python_version<'3.15'
4+
typing_extensions>=4.14.0; python_version>='3.15'
45
mypy_extensions>=1.0.0
56
pathspec>=1.0.0
67
tomli>=1.1.0; python_version<'3.11'

mypyc/lib-rt/misc_ops.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,9 @@ void CPyTrace_LogEvent(const char *location, const char *line, const char *op, c
11581158
typedef struct {
11591159
PyObject_HEAD
11601160
PyObject *name;
1161+
#if CPY_3_15_FEATURES
1162+
PyObject *qualname;
1163+
#endif
11611164
PyObject *type_params;
11621165
PyObject *compute_value;
11631166
PyObject *value;

mypyc/lib-rt/mypyc_util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ static inline CPyTagged CPyTagged_ShortFromSsize_t(Py_ssize_t x) {
160160
#define CPY_3_11_FEATURES (PY_VERSION_HEX >= 0x030b0000)
161161
#define CPY_3_12_FEATURES (PY_VERSION_HEX >= 0x030c0000)
162162
#define CPY_3_14_FEATURES (PY_VERSION_HEX >= 0x030e0000)
163+
#define CPY_3_15_FEATURES (PY_VERSION_HEX >= 0x030f0000)
163164

164165
#if CPY_3_12_FEATURES
165166

mypyc/test-data/run-base64.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ def test_urlsafe_b64decode_errors() -> None:
211211
for b in b"eA", b"eA=", b"eHk":
212212
with assertRaises(ValueError):
213213
b64decode(b)
214+
[out version>=3.15]
215+
driver.py:28: FutureWarning: invalid character '+' in URL-safe Base64 data will be discarded in future Python versions
216+
test_func()
217+
driver.py:28: FutureWarning: invalid character '/' in URL-safe Base64 data will be discarded in future Python versions
218+
test_func()
214219

215220
[case testBase64UsedAtTopLevelOnly_librt]
216221
from librt.base64 import b64encode

mypyc/test-data/run-misc.test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,10 @@ print(z)
971971
[case testCheckVersion]
972972
import sys
973973

974-
if sys.version_info[:2] == (3, 14):
974+
if sys.version_info[:2] == (3, 15):
975+
def version() -> int:
976+
return 15
977+
elif sys.version_info[:2] == (3, 14):
975978
def version() -> int:
976979
return 14
977980
elif sys.version_info[:2] == (3, 13):

mypyc/test-data/run-python312.test

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ EnumLiteralAlias3 = Literal[SomeEnum.AVALUE] | None
199199
[typing fixtures/typing-full.pyi]
200200

201201
[case testPEP695GenericTypeAlias]
202+
import sys
202203
from typing import Callable
203204
from types import GenericAlias
204205

@@ -208,24 +209,36 @@ type A[T] = list[T]
208209

209210
def test_generic_alias() -> None:
210211
assert type(A[str]) is GenericAlias
211-
assert str(A[str]) == "A[str]"
212+
if sys.version_info >= (3, 15): # type: ignore[operator]
213+
assert str(A[str]) == "_frozen_importlib.A[str]"
214+
else:
215+
assert str(A[str]) == "A[str]"
212216
assert str(getattr(A, "__value__")) == "list[T]"
213217

214218
type B[T, S] = dict[S, T]
215219

216220
def test_generic_alias_with_two_args() -> None:
217-
assert str(B[str, int]) == "B[str, int]"
221+
if sys.version_info >= (3, 15): # type: ignore[operator]
222+
assert str(B[str, int]) == "_frozen_importlib.B[str, int]"
223+
else:
224+
assert str(B[str, int]) == "B[str, int]"
218225
assert str(getattr(B, "__value__")) == "dict[S, T]"
219226

220227
type C[*Ts] = tuple[*Ts]
221228

222229
def test_type_var_tuple_type_alias() -> None:
223-
assert str(C[int, str]) == "C[int, str]"
230+
if sys.version_info >= (3, 15): # type: ignore[operator]
231+
assert str(C[int, str]) == "_frozen_importlib.C[int, str]"
232+
else:
233+
assert str(C[int, str]) == "C[int, str]"
224234
assert str(getattr(C, "__value__")) == "tuple[typing.Unpack[Ts]]"
225235

226236
type D[**P] = Callable[P, int]
227237

228238
def test_param_spec_type_alias() -> None:
229-
assert str(D[[int, str]]) == "D[[int, str]]"
239+
if sys.version_info >= (3, 15): # type: ignore[operator]
240+
assert str(D[[int, str]]) == "_frozen_importlib.D[[int, str]]"
241+
else:
242+
assert str(D[[int, str]]) == "D[[int, str]]"
230243
assert str(getattr(D, "__value__")) == "typing.Callable[P, int]"
231244
[typing fixtures/typing-full.pyi]

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ requires = [
55
# self-typechecking :/
66
"setuptools >= 77.0.3",
77
# the following is from mypy-requirements.txt/setup.py
8-
"typing_extensions>=4.6.0",
8+
"typing_extensions>=4.6.0; python_version<'3.15'",
9+
"typing_extensions>=4.14.0; python_version>='3.15'",
910
"mypy_extensions>=1.0.0",
1011
"pathspec>=1.0.0",
1112
"tomli>=1.1.0; python_version<'3.11'",
@@ -49,7 +50,8 @@ classifiers = [
4950
requires-python = ">=3.10"
5051
dependencies = [
5152
# When changing this, also update build-system.requires and mypy-requirements.txt
52-
"typing_extensions>=4.6.0",
53+
"typing_extensions>=4.6.0; python_version<'3.15'",
54+
"typing_extensions>=4.14.0; python_version>='3.15'",
5355
"mypy_extensions>=1.0.0",
5456
"pathspec>=1.0.0",
5557
"tomli>=1.1.0; python_version<'3.11'",

0 commit comments

Comments
 (0)