Make sure that ReadOnly
is removed when using `get_type_hints(inclu… · python/typing_extensions@c3dc681 (original) (raw)
`@@ -4199,6 +4199,20 @@ class AllTheThings(TypedDict):
`
4199
4199
`self.assertEqual(AllTheThings.readonly_keys, frozenset({'a', 'b', 'c'}))
`
4200
4200
`self.assertEqual(AllTheThings.mutable_keys, frozenset({'d'}))
`
4201
4201
``
``
4202
`+
self.assertEqual(
`
``
4203
`+
get_type_hints(AllTheThings, include_extras=False),
`
``
4204
`+
{'a': int, 'b': int, 'c': int, 'd': int},
`
``
4205
`+
)
`
``
4206
`+
self.assertEqual(
`
``
4207
`+
get_type_hints(AllTheThings, include_extras=True),
`
``
4208
`+
{
`
``
4209
`+
'a': Annotated[Required[ReadOnly[int]], 'why not'],
`
``
4210
`+
'b': Required[Annotated[ReadOnly[int], 'why not']],
`
``
4211
`+
'c': ReadOnly[NotRequired[Annotated[int, 'why not']]],
`
``
4212
`+
'd': NotRequired[Annotated[int, 'why not']],
`
``
4213
`+
},
`
``
4214
`+
)
`
``
4215
+
4202
4216
`def test_extra_keys_non_readonly(self):
`
4203
4217
`class Base(TypedDict, closed=True):
`
4204
4218
`extra_items: str
`