Skip to content

Commit 21beadc

Browse files
authored
Enforce typing_extensions >=4.7.0 on py37 (#15556)
The changes made in #15543 mean that mypy's tests will no longer pass if you've got `typing_extensions<4.7` installed and you're running on Python 3.7.
1 parent b995e16 commit 21beadc

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

mypy-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml
2-
typing_extensions>=4.1.0
2+
typing_extensions>=4.1.0; python_version >= '3.8'
3+
typing_extensions>=4.7.0; python_version < '3.8'
34
mypy_extensions>=1.0.0
45
typed_ast>=1.4.0,<2; python_version<'3.8'
56
tomli>=1.1.0; python_version<'3.11'

mypyc/irbuild/classdef.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import typing_extensions
56
from abc import abstractmethod
67
from typing import Callable
78
from typing_extensions import Final
@@ -498,9 +499,14 @@ def populate_non_ext_bases(builder: IRBuilder, cdef: ClassDef) -> Value:
498499
if builder.options.capi_version < (3, 8):
499500
# TypedDict was added to typing in Python 3.8.
500501
module = "typing_extensions"
501-
# It needs to be "_TypedDict" on typing_extensions 4.7.0+
502-
# and "TypedDict" otherwise.
502+
# TypedDict is not a real type on typing_extensions 4.7.0+
503503
name = "_TypedDict"
504+
if isinstance(typing_extensions.TypedDict, type):
505+
raise RuntimeError(
506+
"It looks like you may have an old version "
507+
"of typing_extensions installed. "
508+
"typing_extensions>=4.7.0 is required on Python 3.7."
509+
)
504510
else:
505511
# In Python 3.9 TypedDict is not a real type.
506512
name = "_TypedDict"

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ requires = [
66
"setuptools >= 40.6.2",
77
"wheel >= 0.30.0",
88
# the following is from mypy-requirements.txt
9-
"typing_extensions>=4.1.0",
9+
"typing_extensions>=4.1.0; python_version >= '3.8'",
10+
"typing_extensions>=4.7.0; python_version < '3.8'",
1011
"mypy_extensions>=1.0.0",
1112
"typed_ast>=1.4.0,<2; python_version<'3.8'",
1213
"tomli>=1.1.0; python_version<'3.11'",

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ def run(self):
222222
# When changing this, also update mypy-requirements.txt.
223223
install_requires=[
224224
"typed_ast >= 1.4.0, < 2; python_version<'3.8'",
225-
"typing_extensions>=4.1.0",
225+
"typing_extensions>=4.1.0; python_version >= '3.8'",
226+
"typing_extensions>=4.7.0; python_version < '3.8'",
226227
"mypy_extensions >= 1.0.0",
227228
"tomli>=1.1.0; python_version<'3.11'",
228229
],

0 commit comments

Comments
 (0)