@@ -1375,20 +1375,20 @@ a.append(0) # E: Argument 1 to "append" of "list" has incompatible type "int";
13751375[out]
13761376
13771377[case testInferListInitializedToEmptyAndNotAnnotated]
1378- a = [] # E: Need type annotation for 'a'
1378+ a = [] # E: Need type annotation for 'a' (hint: "a: List[<type>] = ...")
13791379[builtins fixtures/list.pyi]
13801380[out]
13811381
13821382[case testInferListInitializedToEmptyAndReadBeforeAppend]
1383- a = [] # E: Need type annotation for 'a'
1383+ a = [] # E: Need type annotation for 'a' (hint: "a: List[<type>] = ...")
13841384if a: pass
13851385a.xyz # E: "List[Any]" has no attribute "xyz"
13861386a.append('')
13871387[builtins fixtures/list.pyi]
13881388[out]
13891389
13901390[case testInferListInitializedToEmptyAndIncompleteTypeInAppend]
1391- a = [] # E: Need type annotation for 'a'
1391+ a = [] # E: Need type annotation for 'a' (hint: "a: List[<type>] = ...")
13921392a.append([])
13931393a() # E: "List[Any]" not callable
13941394[builtins fixtures/list.pyi]
@@ -1413,7 +1413,7 @@ def f() -> None:
14131413
14141414[case testInferListInitializedToEmptyAndNotAnnotatedInFunction]
14151415def f() -> None:
1416- a = [] # E: Need type annotation for 'a'
1416+ a = [] # E: Need type annotation for 'a' (hint: "a: List[<type>] = ...")
14171417
14181418def g() -> None: pass
14191419
@@ -1424,7 +1424,7 @@ a.append(1)
14241424
14251425[case testInferListInitializedToEmptyAndReadBeforeAppendInFunction]
14261426def f() -> None:
1427- a = [] # E: Need type annotation for 'a'
1427+ a = [] # E: Need type annotation for 'a' (hint: "a: List[<type>] = ...")
14281428 if a: pass
14291429 a.xyz # E: "List[Any]" has no attribute "xyz"
14301430 a.append('')
@@ -1441,7 +1441,7 @@ class A:
14411441
14421442[case testInferListInitializedToEmptyAndNotAnnotatedInClassBody]
14431443class A:
1444- a = [] # E: Need type annotation for 'a'
1444+ a = [] # E: Need type annotation for 'a' (hint: "a: List[<type>] = ...")
14451445
14461446class B:
14471447 a = []
@@ -1461,15 +1461,15 @@ class A:
14611461[case testInferListInitializedToEmptyAndNotAnnotatedInMethod]
14621462class A:
14631463 def f(self) -> None:
1464- a = [] # E: Need type annotation for 'a'
1464+ a = [] # E: Need type annotation for 'a' (hint: "a: List[<type>] = ...")
14651465[builtins fixtures/list.pyi]
14661466[out]
14671467
14681468[case testInferListInitializedToEmptyInMethodViaAttribute]
14691469class A:
14701470 def f(self) -> None:
14711471 # Attributes aren't supported right now.
1472- self.a = [] # E: Need type annotation for 'a'
1472+ self.a = [] # E: Need type annotation for 'a' (hint: "a: List[<type>] = ...")
14731473 self.a.append(1)
14741474 self.a.append('')
14751475[builtins fixtures/list.pyi]
@@ -1480,7 +1480,7 @@ from typing import List
14801480
14811481class A:
14821482 def __init__(self) -> None:
1483- self.x = [] # E: Need type annotation for 'x'
1483+ self.x = [] # E: Need type annotation for 'x' (hint: "x: List[<type>] = ...")
14841484
14851485class B(A):
14861486 # TODO?: This error is kind of a false positive, unfortunately
@@ -1526,16 +1526,16 @@ a() # E: "Dict[str, int]" not callable
15261526[out]
15271527
15281528[case testInferDictInitializedToEmptyUsingUpdateError]
1529- a = {} # E: Need type annotation for 'a'
1529+ a = {} # E: Need type annotation for 'a' (hint: "a: Dict[<type>, <type>] = ...")
15301530a.update([1, 2]) # E: Argument 1 to "update" of "dict" has incompatible type "List[int]"; expected "Mapping[Any, Any]"
15311531a() # E: "Dict[Any, Any]" not callable
15321532[builtins fixtures/dict.pyi]
15331533[out]
15341534
15351535[case testInferDictInitializedToEmptyAndIncompleteTypeInUpdate]
1536- a = {} # E: Need type annotation for 'a'
1536+ a = {} # E: Need type annotation for 'a' (hint: "a: Dict[<type>, <type>] = ...")
15371537a[1] = {}
1538- b = {} # E: Need type annotation for 'b'
1538+ b = {} # E: Need type annotation for 'b' (hint: "b: Dict[<type>, <type>] = ...")
15391539b[{}] = 1
15401540[builtins fixtures/dict.pyi]
15411541[out]
@@ -1555,14 +1555,14 @@ def add():
15551555[case testSpecialCaseEmptyListInitialization]
15561556def f(blocks: Any): # E: Name 'Any' is not defined \
15571557 # N: Did you forget to import it from "typing"? (Suggestion: "from typing import Any")
1558- to_process = [] # E: Need type annotation for 'to_process'
1558+ to_process = [] # E: Need type annotation for 'to_process' (hint: "to_process: List[<type>] = ...")
15591559 to_process = list(blocks)
15601560[builtins fixtures/list.pyi]
15611561[out]
15621562
15631563[case testSpecialCaseEmptyListInitialization2]
15641564def f(blocks: object):
1565- to_process = [] # E: Need type annotation for 'to_process'
1565+ to_process = [] # E: Need type annotation for 'to_process' (hint: "to_process: List[<type>] = ...")
15661566 to_process = list(blocks) # E: No overload variant of "list" matches argument type "object" \
15671567 # N: Possible overload variant: \
15681568 # N: def [T] __init__(self, x: Iterable[T]) -> List[T] \
@@ -1621,7 +1621,7 @@ x.append('') # E: Argument 1 to "append" of "list" has incompatible type "str";
16211621x = None
16221622if object():
16231623 # Promote from partial None to partial list.
1624- x = [] # E: Need type annotation for 'x'
1624+ x = [] # E: Need type annotation for 'x' (hint: "x: List[<type>] = ...")
16251625 x
16261626[builtins fixtures/list.pyi]
16271627
@@ -1630,7 +1630,7 @@ def f() -> None:
16301630 x = None
16311631 if object():
16321632 # Promote from partial None to partial list.
1633- x = [] # E: Need type annotation for 'x'
1633+ x = [] # E: Need type annotation for 'x' (hint: "x: List[<type>] = ...")
16341634[builtins fixtures/list.pyi]
16351635[out]
16361636
@@ -1716,7 +1716,7 @@ class A:
17161716 pass
17171717[builtins fixtures/for.pyi]
17181718[out]
1719- main:3: error: Need type annotation for 'x'
1719+ main:3: error: Need type annotation for 'x' (hint: "x: List[<type>] = ...")
17201720
17211721[case testPartialTypeErrorSpecialCase3]
17221722class A:
@@ -1882,9 +1882,9 @@ o = 1
18821882
18831883[case testMultipassAndPartialTypesSpecialCase3]
18841884def f() -> None:
1885- x = {} # E: Need type annotation for 'x'
1885+ x = {} # E: Need type annotation for 'x' (hint: "x: Dict[<type>, <type>] = ...")
18861886 y = o
1887- z = {} # E: Need type annotation for 'z'
1887+ z = {} # E: Need type annotation for 'z' (hint: "z: Dict[<type>, <type>] = ...")
18881888o = 1
18891889[builtins fixtures/dict.pyi]
18901890[out]
@@ -2070,7 +2070,7 @@ main:4: error: Invalid type: try using Literal[0] instead?
20702070class C:
20712071 x = None
20722072 def __init__(self) -> None:
2073- self.x = [] # E: Need type annotation for 'x'
2073+ self.x = [] # E: Need type annotation for 'x' (hint: "x: List[<type>] = ...")
20742074[builtins fixtures/list.pyi]
20752075[out]
20762076
@@ -2246,7 +2246,7 @@ class A:
22462246[case testLocalPartialTypesWithClassAttributeInitializedToEmptyDict]
22472247# flags: --local-partial-types
22482248class A:
2249- x = {} # E: Need type annotation for 'x'
2249+ x = {} # E: Need type annotation for 'x' (hint: "x: Dict[<type>, <type>] = ...")
22502250
22512251 def f(self) -> None:
22522252 self.x[0] = ''
@@ -2269,7 +2269,7 @@ reveal_type(a) # E: Revealed type is 'builtins.list[builtins.int]'
22692269
22702270[case testLocalPartialTypesWithGlobalInitializedToEmptyList2]
22712271# flags: --local-partial-types
2272- a = [] # E: Need type annotation for 'a'
2272+ a = [] # E: Need type annotation for 'a' (hint: "a: List[<type>] = ...")
22732273
22742274def f() -> None:
22752275 a.append(1)
@@ -2280,7 +2280,7 @@ reveal_type(a) # E: Revealed type is 'builtins.list[Any]'
22802280
22812281[case testLocalPartialTypesWithGlobalInitializedToEmptyList3]
22822282# flags: --local-partial-types
2283- a = [] # E: Need type annotation for 'a'
2283+ a = [] # E: Need type annotation for 'a' (hint: "a: List[<type>] = ...")
22842284
22852285def f():
22862286 a.append(1)
@@ -2302,7 +2302,7 @@ reveal_type(a) # E: Revealed type is 'builtins.dict[builtins.int, builtins.str]'
23022302
23032303[case testLocalPartialTypesWithGlobalInitializedToEmptyDict2]
23042304# flags: --local-partial-types
2305- a = {} # E: Need type annotation for 'a'
2305+ a = {} # E: Need type annotation for 'a' (hint: "a: Dict[<type>, <type>] = ...")
23062306
23072307def f() -> None:
23082308 a[0] = ''
@@ -2313,7 +2313,7 @@ reveal_type(a) # E: Revealed type is 'builtins.dict[Any, Any]'
23132313
23142314[case testLocalPartialTypesWithGlobalInitializedToEmptyDict3]
23152315# flags: --local-partial-types
2316- a = {} # E: Need type annotation for 'a'
2316+ a = {} # E: Need type annotation for 'a' (hint: "a: Dict[<type>, <type>] = ...")
23172317
23182318def f():
23192319 a[0] = ''
0 commit comments