FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.9] gh-92106: Add test that subscription works on arbitrary TypedDicts (GH-92176) by miss-islington · Pull Request #92201 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
13 changes: 13 additions & 0 deletions Lib/test/test_typing.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL