diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 88be2850acb1cc..7f36a421a58595 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -5811,6 +5811,8 @@ def test_typeddict_errors(self): isinstance(jim, Emp) with self.assertRaises(TypeError): issubclass(dict, Emp) + with self.assertRaises(TypeError): + Emp[int, str] with self.assertRaises(TypeError): TypedDict('Hi', [('x', int)], y=int) diff --git a/Lib/typing.py b/Lib/typing.py index 35deb32220eb88..c9c190f4a1b4ff 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -2883,6 +2883,7 @@ def __new__(cls, name, bases, ns, total=True): tp_dict.__optional_keys__ = frozenset(optional_keys) if not hasattr(tp_dict, '__total__'): tp_dict.__total__ = total + tp_dict.__class_getitem__ = None return tp_dict __call__ = dict # static method diff --git a/Misc/NEWS.d/next/Library/2022-05-01-16-58-31.gh-issue-92106.qjt1Gq.rst b/Misc/NEWS.d/next/Library/2022-05-01-16-58-31.gh-issue-92106.qjt1Gq.rst new file mode 100644 index 00000000000000..941ebeb84adb69 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-05-01-16-58-31.gh-issue-92106.qjt1Gq.rst @@ -0,0 +1,2 @@ +:class:`typing.TypedDict` types are non-generic by default. Subscripting +them raises now TypeError.