@@ -60,13 +60,13 @@ p = Point({x: 42, 'y': 1337}) # E: Expected TypedDict key to be string literal
60
60
[case testCannotCreateTypedDictInstanceWithExtraItems]
61
61
from mypy_extensions import TypedDict
62
62
Point = TypedDict('Point', {'x': int, 'y': int})
63
- p = Point(x=42, y=1337, z=666) # E: Extra key 'z' for TypedDict "Point"
63
+ p = Point(x=42, y=1337, z=666) # E: Extra key "z" for TypedDict "Point"
64
64
[builtins fixtures/dict.pyi]
65
65
66
66
[case testCannotCreateTypedDictInstanceWithMissingItems]
67
67
from mypy_extensions import TypedDict
68
68
Point = TypedDict('Point', {'x': int, 'y': int})
69
- p = Point(x=42) # E: Missing key 'y' for TypedDict "Point"
69
+ p = Point(x=42) # E: Missing key "y" for TypedDict "Point"
70
70
[builtins fixtures/dict.pyi]
71
71
72
72
[case testCannotCreateTypedDictInstanceWithIncompatibleItemType]
@@ -149,7 +149,7 @@ def foo(x):
149
149
# type: (Movie) -> None
150
150
pass
151
151
152
- foo({}) # E: Missing keys (' name', ' year' ) for TypedDict "Movie"
152
+ foo({}) # E: Missing keys (" name", " year" ) for TypedDict "Movie"
153
153
foo({'name': 'lol', 'year': 2009, 'based_on': 0}) # E: Incompatible types (expression has type "int", TypedDict item "based_on" has type "str")
154
154
155
155
[builtins fixtures/dict.pyi]
@@ -871,15 +871,15 @@ Point = TypedDict('Point', {'x': int, 'y': int})
871
871
def f(p: Point) -> None:
872
872
if int():
873
873
p = {'x': 2, 'y': 3}
874
- p = {'x': 2} # E: Missing key 'y' for TypedDict "Point"
874
+ p = {'x': 2} # E: Missing key "y" for TypedDict "Point"
875
875
p = dict(x=2, y=3)
876
876
877
877
f({'x': 1, 'y': 3})
878
878
f({'x': 1, 'y': 'z'}) # E: Incompatible types (expression has type "str", TypedDict item "y" has type "int")
879
879
880
880
f(dict(x=1, y=3))
881
- f(dict(x=1, y=3, z=4)) # E: Extra key 'z' for TypedDict "Point"
882
- f(dict(x=1, y=3, z=4, a=5)) # E: Extra keys ('z', 'a' ) for TypedDict "Point"
881
+ f(dict(x=1, y=3, z=4)) # E: Extra key "z" for TypedDict "Point"
882
+ f(dict(x=1, y=3, z=4, a=5)) # E: Extra keys ("z", "a" ) for TypedDict "Point"
883
883
884
884
[builtins fixtures/dict.pyi]
885
885
@@ -888,15 +888,15 @@ from mypy_extensions import TypedDict
888
888
889
889
Point = TypedDict('Point', {'x': int, 'y': int})
890
890
891
- p1a: Point = {'x': 'hi'} # E: Missing key 'y' for TypedDict "Point"
892
- p1b: Point = {} # E: Missing keys ('x', 'y' ) for TypedDict "Point"
891
+ p1a: Point = {'x': 'hi'} # E: Missing key "y" for TypedDict "Point"
892
+ p1b: Point = {} # E: Missing keys ("x", "y" ) for TypedDict "Point"
893
893
894
894
p2: Point
895
- p2 = dict(x='bye') # E: Missing key 'y' for TypedDict "Point"
895
+ p2 = dict(x='bye') # E: Missing key "y" for TypedDict "Point"
896
896
897
897
p3 = Point(x=1, y=2)
898
898
if int():
899
- p3 = {'x': 'hi'} # E: Missing key 'y' for TypedDict "Point"
899
+ p3 = {'x': 'hi'} # E: Missing key "y" for TypedDict "Point"
900
900
901
901
p4: Point = {'x': 1, 'y': 2}
902
902
@@ -911,7 +911,7 @@ T = TypeVar('T')
911
911
def join(x: T, y: T) -> T: return x
912
912
ab = join(A(x=1, y=1), B(x=1, y=''))
913
913
if int():
914
- ab = {'x': 1, 'z': 1} # E: Expected TypedDict key 'x' but found keys ('x', 'z' )
914
+ ab = {'x': 1, 'z': 1} # E: Expected TypedDict key "x" but found keys ("x", "z" )
915
915
[builtins fixtures/dict.pyi]
916
916
917
917
[case testCannotCreateAnonymousTypedDictInstanceUsingDictLiteralWithMissingItems]
@@ -923,7 +923,7 @@ T = TypeVar('T')
923
923
def join(x: T, y: T) -> T: return x
924
924
ab = join(A(x=1, y=1, z=1), B(x=1, y=1, z=''))
925
925
if int():
926
- ab = {} # E: Expected TypedDict keys ('x', 'y' ) but found no keys
926
+ ab = {} # E: Expected TypedDict keys ("x", "y" ) but found no keys
927
927
[builtins fixtures/dict.pyi]
928
928
929
929
@@ -1044,7 +1044,7 @@ f({})
1044
1044
f({'x': 1})
1045
1045
f({'y': ''})
1046
1046
f({'x': 1, 'y': ''})
1047
- f({'x': 1, 'z': ''}) # E: Extra key 'z' for TypedDict "D"
1047
+ f({'x': 1, 'z': ''}) # E: Extra key "z" for TypedDict "D"
1048
1048
f({'x': ''}) # E: Incompatible types (expression has type "str", TypedDict item "x" has type "int")
1049
1049
[builtins fixtures/dict.pyi]
1050
1050
@@ -1056,7 +1056,7 @@ reveal_type(D()) # N: Revealed type is "TypedDict('__main__.D', {'x'?: builtins.
1056
1056
reveal_type(D(x=1)) # N: Revealed type is "TypedDict('__main__.D', {'x'?: builtins.int, 'y'?: builtins.str})"
1057
1057
f(D(y=''))
1058
1058
f(D(x=1, y=''))
1059
- f(D(x=1, z='')) # E: Extra key 'z' for TypedDict "D"
1059
+ f(D(x=1, z='')) # E: Extra key "z" for TypedDict "D"
1060
1060
f(D(x='')) # E: Incompatible types (expression has type "str", TypedDict item "x" has type "int")
1061
1061
[builtins fixtures/dict.pyi]
1062
1062
@@ -1614,9 +1614,9 @@ a.update({'x': 1})
1614
1614
a.update({'x': ''}) # E: Incompatible types (expression has type "str", TypedDict item "x" has type "int")
1615
1615
a.update({'x': 1, 'y': []})
1616
1616
a.update({'x': 1, 'y': [1]})
1617
- a.update({'z': 1}) # E: Unexpected TypedDict key 'z'
1618
- a.update({'z': 1, 'zz': 1}) # E: Unexpected TypedDict keys ('z', 'zz' )
1619
- a.update({'z': 1, 'x': 1}) # E: Expected TypedDict key 'x' but found keys ('z', 'x' )
1617
+ a.update({'z': 1}) # E: Unexpected TypedDict key "z"
1618
+ a.update({'z': 1, 'zz': 1}) # E: Unexpected TypedDict keys ("z", "zz" )
1619
+ a.update({'z': 1, 'x': 1}) # E: Expected TypedDict key "x" but found keys ("z", "x" )
1620
1620
d = {'x': 1}
1621
1621
a.update(d) # E: Argument 1 to "update" of "TypedDict" has incompatible type "Dict[str, int]"; expected "TypedDict({'x'?: int, 'y'?: List[int]})"
1622
1622
[builtins fixtures/dict.pyi]
@@ -1977,7 +1977,7 @@ v = {union: 2} # E: Expected TypedDict key to be string literal
1977
1977
num2: Literal['num']
1978
1978
v = {num2: 2}
1979
1979
bad2: Literal['bad']
1980
- v = {bad2: 2} # E: Extra key ' bad' for TypedDict "Value"
1980
+ v = {bad2: 2} # E: Extra key " bad" for TypedDict "Value"
1981
1981
1982
1982
[builtins fixtures/dict.pyi]
1983
1983
[typing fixtures/typing-typeddict.pyi]
@@ -2107,5 +2107,5 @@ d[True] # E: TypedDict key must be a string literal; expected one of ('foo')
2107
2107
from mypy_extensions import TypedDict
2108
2108
2109
2109
Foo = TypedDict('Foo', {'camelCaseKey': str})
2110
- value: Foo = {} # E: Missing key ' camelCaseKey' for TypedDict "Foo"
2110
+ value: Foo = {} # E: Missing key " camelCaseKey" for TypedDict "Foo"
2111
2111
[builtins fixtures/dict.pyi]
0 commit comments