Skip to content

Commit

Permalink
gh-92106: Add test that subscription works on arbitrary TypedDicts (G…
Browse files Browse the repository at this point in the history
…H-92176)

(cherry picked from commit 81fb354)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
miss-islington and serhiy-storchaka committed May 3, 2022
1 parent 51b885a commit 7e55730
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Lib/test/test_typing.py
Expand Up @@ -4076,6 +4076,19 @@ def test_get_type_hints(self):
{'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 IOTests(BaseTestCase):

Expand Down

0 comments on commit 7e55730

Please sign in to comment.