diff --git a/mypy-requirements.txt b/mypy-requirements.txt index 6949405d9a9c..19086e49393b 100644 --- a/mypy-requirements.txt +++ b/mypy-requirements.txt @@ -1,6 +1,7 @@ # NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml # and the pins in setup.py -typing_extensions>=4.6.0 +typing_extensions>=4.6.0; python_version<'3.15' +typing_extensions>=4.14.0; python_version>='3.15' mypy_extensions>=1.0.0 pathspec>=1.0.0 tomli>=1.1.0; python_version<'3.11' diff --git a/mypyc/lib-rt/misc_ops.c b/mypyc/lib-rt/misc_ops.c index e083d60e78d7..a13243fc40d6 100644 --- a/mypyc/lib-rt/misc_ops.c +++ b/mypyc/lib-rt/misc_ops.c @@ -1158,6 +1158,9 @@ void CPyTrace_LogEvent(const char *location, const char *line, const char *op, c typedef struct { PyObject_HEAD PyObject *name; +#if CPY_3_15_FEATURES + PyObject *qualname; +#endif PyObject *type_params; PyObject *compute_value; PyObject *value; diff --git a/mypyc/lib-rt/mypyc_util.h b/mypyc/lib-rt/mypyc_util.h index 6715d67d9657..4a4552d059b8 100644 --- a/mypyc/lib-rt/mypyc_util.h +++ b/mypyc/lib-rt/mypyc_util.h @@ -160,6 +160,7 @@ static inline CPyTagged CPyTagged_ShortFromSsize_t(Py_ssize_t x) { #define CPY_3_11_FEATURES (PY_VERSION_HEX >= 0x030b0000) #define CPY_3_12_FEATURES (PY_VERSION_HEX >= 0x030c0000) #define CPY_3_14_FEATURES (PY_VERSION_HEX >= 0x030e0000) +#define CPY_3_15_FEATURES (PY_VERSION_HEX >= 0x030f0000) #if CPY_3_12_FEATURES diff --git a/mypyc/test-data/run-base64.test b/mypyc/test-data/run-base64.test index 2809539fe5ec..022a0e8c3113 100644 --- a/mypyc/test-data/run-base64.test +++ b/mypyc/test-data/run-base64.test @@ -211,6 +211,11 @@ def test_urlsafe_b64decode_errors() -> None: for b in b"eA", b"eA=", b"eHk": with assertRaises(ValueError): b64decode(b) +[out version>=3.15] +driver.py:28: FutureWarning: invalid character '+' in URL-safe Base64 data will be discarded in future Python versions + test_func() +driver.py:28: FutureWarning: invalid character '/' in URL-safe Base64 data will be discarded in future Python versions + test_func() [case testBase64UsedAtTopLevelOnly_librt] from librt.base64 import b64encode diff --git a/mypyc/test-data/run-misc.test b/mypyc/test-data/run-misc.test index 1632256b7474..142b5045ef49 100644 --- a/mypyc/test-data/run-misc.test +++ b/mypyc/test-data/run-misc.test @@ -971,7 +971,10 @@ print(z) [case testCheckVersion] import sys -if sys.version_info[:2] == (3, 14): +if sys.version_info[:2] == (3, 15): + def version() -> int: + return 15 +elif sys.version_info[:2] == (3, 14): def version() -> int: return 14 elif sys.version_info[:2] == (3, 13): diff --git a/mypyc/test-data/run-python312.test b/mypyc/test-data/run-python312.test index 5c0a807c375a..5ed6dca9ecb2 100644 --- a/mypyc/test-data/run-python312.test +++ b/mypyc/test-data/run-python312.test @@ -199,6 +199,7 @@ EnumLiteralAlias3 = Literal[SomeEnum.AVALUE] | None [typing fixtures/typing-full.pyi] [case testPEP695GenericTypeAlias] +import sys from typing import Callable from types import GenericAlias @@ -208,24 +209,36 @@ type A[T] = list[T] def test_generic_alias() -> None: assert type(A[str]) is GenericAlias - assert str(A[str]) == "A[str]" + if sys.version_info >= (3, 15): # type: ignore[operator] + assert str(A[str]) == "_frozen_importlib.A[str]" + else: + assert str(A[str]) == "A[str]" assert str(getattr(A, "__value__")) == "list[T]" type B[T, S] = dict[S, T] def test_generic_alias_with_two_args() -> None: - assert str(B[str, int]) == "B[str, int]" + if sys.version_info >= (3, 15): # type: ignore[operator] + assert str(B[str, int]) == "_frozen_importlib.B[str, int]" + else: + assert str(B[str, int]) == "B[str, int]" assert str(getattr(B, "__value__")) == "dict[S, T]" type C[*Ts] = tuple[*Ts] def test_type_var_tuple_type_alias() -> None: - assert str(C[int, str]) == "C[int, str]" + if sys.version_info >= (3, 15): # type: ignore[operator] + assert str(C[int, str]) == "_frozen_importlib.C[int, str]" + else: + assert str(C[int, str]) == "C[int, str]" assert str(getattr(C, "__value__")) == "tuple[typing.Unpack[Ts]]" type D[**P] = Callable[P, int] def test_param_spec_type_alias() -> None: - assert str(D[[int, str]]) == "D[[int, str]]" + if sys.version_info >= (3, 15): # type: ignore[operator] + assert str(D[[int, str]]) == "_frozen_importlib.D[[int, str]]" + else: + assert str(D[[int, str]]) == "D[[int, str]]" assert str(getattr(D, "__value__")) == "typing.Callable[P, int]" [typing fixtures/typing-full.pyi] diff --git a/pyproject.toml b/pyproject.toml index 8aa2a5b619cc..9f55d97ef9e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,8 @@ requires = [ # self-typechecking :/ "setuptools >= 77.0.3", # the following is from mypy-requirements.txt/setup.py - "typing_extensions>=4.6.0", + "typing_extensions>=4.6.0; python_version<'3.15'", + "typing_extensions>=4.14.0; python_version>='3.15'", "mypy_extensions>=1.0.0", "pathspec>=1.0.0", "tomli>=1.1.0; python_version<'3.11'", @@ -49,7 +50,8 @@ classifiers = [ requires-python = ">=3.10" dependencies = [ # When changing this, also update build-system.requires and mypy-requirements.txt - "typing_extensions>=4.6.0", + "typing_extensions>=4.6.0; python_version<'3.15'", + "typing_extensions>=4.14.0; python_version>='3.15'", "mypy_extensions>=1.0.0", "pathspec>=1.0.0", "tomli>=1.1.0; python_version<'3.11'",