Skip to content

Commit

Permalink
Enforce typing_extensions >=4.7.0 on py37 (#15556)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AlexWaygood authored Jun 30, 2023
1 parent b995e16 commit 21beadc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion mypy-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# NOTE: this needs to be kept in sync with the "requires" list in pyproject.toml
typing_extensions>=4.1.0
typing_extensions>=4.1.0; python_version >= '3.8'
typing_extensions>=4.7.0; python_version < '3.8'
mypy_extensions>=1.0.0
typed_ast>=1.4.0,<2; python_version<'3.8'
tomli>=1.1.0; python_version<'3.11'
10 changes: 8 additions & 2 deletions mypyc/irbuild/classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import typing_extensions
from abc import abstractmethod
from typing import Callable
from typing_extensions import Final
Expand Down Expand Up @@ -498,9 +499,14 @@ def populate_non_ext_bases(builder: IRBuilder, cdef: ClassDef) -> Value:
if builder.options.capi_version < (3, 8):
# TypedDict was added to typing in Python 3.8.
module = "typing_extensions"
# It needs to be "_TypedDict" on typing_extensions 4.7.0+
# and "TypedDict" otherwise.
# TypedDict is not a real type on typing_extensions 4.7.0+
name = "_TypedDict"
if isinstance(typing_extensions.TypedDict, type):
raise RuntimeError(
"It looks like you may have an old version "
"of typing_extensions installed. "
"typing_extensions>=4.7.0 is required on Python 3.7."
)
else:
# In Python 3.9 TypedDict is not a real type.
name = "_TypedDict"
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ requires = [
"setuptools >= 40.6.2",
"wheel >= 0.30.0",
# the following is from mypy-requirements.txt
"typing_extensions>=4.1.0",
"typing_extensions>=4.1.0; python_version >= '3.8'",
"typing_extensions>=4.7.0; python_version < '3.8'",
"mypy_extensions>=1.0.0",
"typed_ast>=1.4.0,<2; python_version<'3.8'",
"tomli>=1.1.0; python_version<'3.11'",
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def run(self):
# When changing this, also update mypy-requirements.txt.
install_requires=[
"typed_ast >= 1.4.0, < 2; python_version<'3.8'",
"typing_extensions>=4.1.0",
"typing_extensions>=4.1.0; python_version >= '3.8'",
"typing_extensions>=4.7.0; python_version < '3.8'",
"mypy_extensions >= 1.0.0",
"tomli>=1.1.0; python_version<'3.11'",
],
Expand Down

0 comments on commit 21beadc

Please sign in to comment.