@@ -336,21 +336,6 @@ D = TypedDict('D', {'x': List[int]})
336
336
reveal_type(D(x=[])) # E: Revealed type is 'TypedDict('__main__.D', {'x': builtins.list[builtins.int]})'
337
337
[builtins fixtures/dict.pyi]
338
338
339
- -- TODO: Fix mypy stubs so that the following passes in the test suite
340
- --[case testCanConvertTypedDictToAnySuperclassOfMapping]
341
- --from mypy_extensions import TypedDict
342
- --from typing import Sized, Iterable, Container
343
- --Point = TypedDict('Point', {'x': int, 'y': int})
344
- --def as_sized(p: Point) -> Sized:
345
- -- return p
346
- --def as_iterable(p: Point) -> Iterable[str]:
347
- -- return p
348
- --def as_container(p: Point) -> Container[str]:
349
- -- return p
350
- --def as_object(p: Point) -> object:
351
- -- return p
352
- --[builtins fixtures/dict.pyi]
353
-
354
339
[case testCannotConvertTypedDictToDictOrMutableMapping]
355
340
from mypy_extensions import TypedDict
356
341
from typing import Dict, MutableMapping
@@ -439,18 +424,18 @@ reveal_type(joined1) # E: Revealed type is 'builtins.list[typing.Mapping*[built
439
424
reveal_type(joined2) # E: Revealed type is 'builtins.list[typing.Mapping*[builtins.str, builtins.int]]'
440
425
[builtins fixtures/dict.pyi]
441
426
442
- -- TODO: Fix mypy stubs so that the following passes in the test suite
443
- --[case testJoinOfTypedDictWithCompatibleMappingSupertypeIsSupertype]
444
- -- from mypy_extensions import TypedDict
445
- --from typing import Sized
446
- --Cell = TypedDict(' Cell', {' value': int} )
447
- --left = Cell(value=42)
448
- --right = {'score': 999} # type: Sized
449
- --joined1 = [left, right ]
450
- --joined2 = [right, left]
451
- -- reveal_type(joined1 ) # E: Revealed type is 'builtins.list[typing.Sized*]'
452
- --reveal_type(joined2) # E: Revealed type is ' builtins.list[typing.Sized*]'
453
- --[builtins fixtures/dict .pyi]
427
+ [case testJoinOfTypedDictWithCompatibleMappingSupertypeIsSupertype]
428
+ from mypy_extensions import TypedDict
429
+ from typing import Sized
430
+ Cell = TypedDict('Cell', {'value': int})
431
+ left = Cell( value=42 )
432
+ right = {'score': 999} # type: Sized
433
+ joined1 = [left, right]
434
+ joined2 = [right, left ]
435
+ reveal_type(joined1) # E: Revealed type is 'builtins.list[typing.Sized*]'
436
+ reveal_type(joined2 ) # E: Revealed type is 'builtins.list[typing.Sized*]'
437
+ [ builtins fixtures/dict.pyi]
438
+ [typing fixtures/typing-full .pyi]
454
439
455
440
[case testJoinOfTypedDictWithIncompatibleMappingIsObject]
456
441
from mypy_extensions import TypedDict
@@ -602,26 +587,6 @@ reveal_type(f(a)) # E: Revealed type is 'builtins.str*'
602
587
-- TODO: Figure out some way to trigger the ConstraintBuilderVisitor.visit_typeddict_type() path.
603
588
604
589
605
- -- Methods
606
-
607
- -- TODO: iter() does not accept TypedDictType as an argument type. Figure out why.
608
- --[case testCanCallMappingMethodsOnTypedDict]
609
- --from mypy_extensions import TypedDict
610
- --Cell = TypedDict('Cell', {'value': int})
611
- --c = Cell(value=42)
612
- --c['value']
613
- --iter(c)
614
- --len(c)
615
- --'value' in c
616
- --c.keys()
617
- --c.items()
618
- --c.values()
619
- --c.get('value')
620
- --c == c
621
- --c != c
622
- --[builtins fixtures/dict.pyi]
623
-
624
-
625
590
-- Special Method: __getitem__
626
591
627
592
[case testCanGetItemOfTypedDictWithValidStringLiteralKey]
@@ -707,14 +672,6 @@ def set_coordinate(p: TaggedPoint, key: str, value: int) -> None:
707
672
[builtins fixtures/dict.pyi]
708
673
709
674
710
- -- Special Method: get
711
-
712
- -- TODO: Implement support for these cases:
713
- --[case testGetOfTypedDictWithValidStringLiteralKeyReturnsPreciseType]
714
- --[case testGetOfTypedDictWithInvalidStringLiteralKeyIsError]
715
- --[case testGetOfTypedDictWithNonLiteralKeyReturnsImpreciseType]
716
-
717
-
718
675
-- isinstance
719
676
720
677
[case testTypedDictAndInstance]
@@ -726,7 +683,8 @@ if isinstance(d, D): # E: Cannot use isinstance() with a TypedDict type
726
683
[builtins fixtures/isinstancelist.pyi]
727
684
728
685
729
- -- scoping
686
+ -- Scoping
687
+
730
688
[case testTypedDictInClassNamespace]
731
689
# https://github.com/python/mypy/pull/2553#issuecomment-266474341
732
690
from mypy_extensions import TypedDict
0 commit comments