Skip to content

[3.9] gh-92106: Add test that subscription works on arbitrary TypedDicts (GH-92176) #92201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
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