Skip to content

Commit bec0dd3

Browse files
authored
Remove old TypedDict + NamedTuple code from mypyc (#18554)
Mypyc requires Python 3.9+. This PR removes the old TypedDict and NamedTuple code for versions prior to 3.9.
1 parent e2b821b commit bec0dd3

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

mypyc/irbuild/classdef.py

+2-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import typing_extensions
65
from abc import abstractmethod
76
from typing import Callable, Final
87

@@ -542,29 +541,10 @@ def populate_non_ext_bases(builder: IRBuilder, cdef: ClassDef) -> Value:
542541
# HAX: Mypy internally represents TypedDict classes differently from what
543542
# should happen at runtime. Replace with something that works.
544543
module = "typing"
545-
if builder.options.capi_version < (3, 9):
546-
name = "TypedDict"
547-
if builder.options.capi_version < (3, 8):
548-
# TypedDict was added to typing in Python 3.8.
549-
module = "typing_extensions"
550-
# TypedDict is not a real type on typing_extensions 4.7.0+
551-
name = "_TypedDict"
552-
if isinstance(typing_extensions.TypedDict, type):
553-
raise RuntimeError(
554-
"It looks like you may have an old version "
555-
"of typing_extensions installed. "
556-
"typing_extensions>=4.7.0 is required on Python 3.7."
557-
)
558-
else:
559-
# In Python 3.9 TypedDict is not a real type.
560-
name = "_TypedDict"
544+
name = "_TypedDict"
561545
base = builder.get_module_attr(module, name, cdef.line)
562546
elif is_named_tuple and cls.fullname == "builtins.tuple":
563-
if builder.options.capi_version < (3, 9):
564-
name = "NamedTuple"
565-
else:
566-
# This was changed in Python 3.9.
567-
name = "_NamedTuple"
547+
name = "_NamedTuple"
568548
base = builder.get_module_attr("typing", name, cdef.line)
569549
else:
570550
cls_module = cls.fullname.rsplit(".", 1)[0]

0 commit comments

Comments
 (0)