@@ -1153,7 +1153,7 @@ for xx, yy, zz in [(A(), B())]: # E: Need more than 2 values to unpack (3 expect
11531153 pass
11541154for xx, (yy, zz) in [(A(), B())]: # E: "B" object is not iterable
11551155 pass
1156- for xxx, yyy in [(None, None )]:
1156+ for xxx, yyy in [(1, 2 )]:
11571157 pass
11581158[builtins fixtures/for.pyi]
11591159
@@ -2125,19 +2125,66 @@ main:6: error: Incompatible types in assignment (expression has type "int", vari
21252125main:7: error: "None" not callable
21262126
21272127[case testGlobalInitializedToNoneSetFromFunction]
2128+ # flags: --no-local-partial-types
21282129a = None
2129- def f():
2130+ def f() -> None :
21302131 global a
21312132 a = 42
2132- [out]
2133+ reveal_type(a) # N: Revealed type is "builtins.int"
2134+ reveal_type(a) # N: Revealed type is "builtins.int | None"
2135+
2136+ b = None
2137+ def unchecked():
2138+ global b
2139+ b = 42
2140+ reveal_type(b) # N: Revealed type is "Any | None"
2141+
2142+ [case testGlobalInitializedToNoneSetFromFunctionLocalPartialTypes]
2143+ # flags: --local-partial-types
2144+ a = None # E: Need type annotation for "a" (hint: "a: <type> | None = ...")
2145+ def f() -> None:
2146+ global a
2147+ a = 42
2148+ reveal_type(a) # N: Revealed type is "builtins.int"
2149+ reveal_type(a) # N: Revealed type is "None"
2150+
2151+ b = None # E: Need type annotation for "b" (hint: "b: <type> | None = ...")
2152+ def unchecked():
2153+ global b
2154+ b = 42
2155+ reveal_type(b) # N: Revealed type is "None"
21332156
21342157[case testGlobalInitializedToNoneSetFromMethod]
2158+ # flags: --no-local-partial-types
21352159a = None
21362160class C:
2137- def m(self):
2161+ def m(self) -> None :
21382162 global a
21392163 a = 42
2140- [out]
2164+ reveal_type(a) # N: Revealed type is "builtins.int | None"
2165+
2166+ b = None
2167+ class CC:
2168+ def unchecked(self):
2169+ global b
2170+ b = 42
2171+ reveal_type(b) # N: Revealed type is "Any | None"
2172+
2173+ [case testGlobalInitializedToNoneSetFromMethodLocalPartialTypes]
2174+ # flags: --local-partial-types
2175+ a = None # E: Need type annotation for "a" (hint: "a: <type> | None = ...")
2176+ class C:
2177+ def m(self) -> None:
2178+ global a
2179+ a = 42
2180+ reveal_type(a) # N: Revealed type is "None"
2181+
2182+ b = None # E: Need type annotation for "b" (hint: "b: <type> | None = ...")
2183+ class CC:
2184+ def unchecked(self):
2185+ global b
2186+ b = 42
2187+ reveal_type(b) # N: Revealed type is "None"
21412188
21422189-- More partial type errors
21432190-- ------------------------
0 commit comments