File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1336,3 +1336,23 @@ _program.py:13: error: Revealed type is 'def (x: builtins.int) -> contextlib.Gen
1336
1336
_program.py:14: error: Revealed type is 'def (*x: builtins.str) -> contextlib.GeneratorContextManager[builtins.int*]'
1337
1337
_program.py:16: error: Argument 1 to "f" has incompatible type "str"; expected "int"
1338
1338
_program.py:17: error: Revealed type is 'builtins.str*'
1339
+
1340
+ [case testTypedDictGet]
1341
+ # Test that TypedDict get plugin works with typeshed stubs
1342
+ # TODO: Make it possible to use strict optional here
1343
+ from mypy_extensions import TypedDict
1344
+ class A: pass
1345
+ D = TypedDict('D', {'x': int, 'y': str})
1346
+ d: D
1347
+ reveal_type(d.get('x'))
1348
+ reveal_type(d.get('y'))
1349
+ d.get('z')
1350
+ d.get()
1351
+ s = ''
1352
+ d.get(s)
1353
+ [out]
1354
+ _testTypedDictGet.py:7: error: Revealed type is 'builtins.int'
1355
+ _testTypedDictGet.py:8: error: Revealed type is 'builtins.str'
1356
+ _testTypedDictGet.py:9: error: 'z' is not a valid item name; expected one of ['x', 'y']
1357
+ _testTypedDictGet.py:10: error: No overload variant of "get" of "Mapping" matches argument types []
1358
+ _testTypedDictGet.py:12: error: Cannot prove expression is a valid item name; expected one of ['x', 'y']
You can’t perform that action at this time.
0 commit comments