From: Serhiy Storchaka Date: Mon, 2 May 2022 22:38:39 +0000 (+0300) Subject: gh-92106: Add test that subscription works on arbitrary TypedDicts (#92176) X-Git-Tag: v3.11.0b1~111 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=81fb3548be5a18bf40a6f4505a02cc7fb72c9c34;p=thirdparty%2FPython%2Fcpython.git gh-92106: Add test that subscription works on arbitrary TypedDicts (#92176) --- diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 88be2850acb1..cb7ca3610b06 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -6024,6 +6024,19 @@ class TypedDictTests(BaseTestCase): {'a': typing.Optional[int], 'b': int} ) + def test_non_generic_subscript(self): + # For backward compatibility, subscription works + # on arbitrary TypedDict types. + class TD(TypedDict): + a: T + A = TD[int] + self.assertEqual(A.__origin__, TD) + self.assertEqual(A.__parameters__, ()) + self.assertEqual(A.__args__, (int,)) + a = A(a = 1) + self.assertIs(type(a), dict) + self.assertEqual(a, {'a': 1}) + class RequiredTests(BaseTestCase):