Skip to content

Commit 166a911

Browse files
committed
Add test case that uses typeshed stubs
1 parent 753d52c commit 166a911

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test-data/unit/pythoneval.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,3 +1336,23 @@ _program.py:13: error: Revealed type is 'def (x: builtins.int) -> contextlib.Gen
13361336
_program.py:14: error: Revealed type is 'def (*x: builtins.str) -> contextlib.GeneratorContextManager[builtins.int*]'
13371337
_program.py:16: error: Argument 1 to "f" has incompatible type "str"; expected "int"
13381338
_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']

0 commit comments

Comments
 (0)