8000 gh-92106: Add test that subscription works on arbitrary TypedDicts (#… · python/cpython@81fb354 · GitHub
[go: up one dir, main page]

Skip to content

Commit 81fb354

Browse files
gh-92106: Add test that subscription works on arbitrary TypedDicts (#92176)
1 parent 4bed9c4 commit 81fb354

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Lib/test/test_typing.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6024,6 +6024,19 @@ def test_get_type_hints(self):
60246024
{'a': typing.Optional[int], 'b': int}
60256025
)
60266026

6027+
def test_non_generic_subscript(self):
6028+
# For backward compatibility, subscription works
6029+
# on arbitrary TypedDict types.
6030+
class TD(TypedDict):
6031+
a: T
6032+
A = TD[int]
6033+
self.assertEqual(A.__origin__, TD)
6034+
self.assertEqual(A.__parameters__, ())
6035+
self.assertEqual(A.__args__, (int,))
6036+
a = A(a = 1)
6037+
self.assertIs(type(a), dict)
6038+
self.assertEqual(a, {'a': 1})
6039+
60276040

60286041
class RequiredTests(BaseTestCase):
60296042

0 commit comments

Comments
 (0)
0