Skip to content

Commit 4a46238

Browse files
committed
add tests back (file got renamed)
1 parent e765e32 commit 4a46238

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test-data/unit/check-python38.test

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,52 @@ def f(p1: bytes, p2: float, /, p_or_kw: int) -> None:
181181
def f(p1: bytes, p2: float, /) -> None:
182182
reveal_type(p1) # E: Revealed type is 'builtins.bytes'
183183
reveal_type(p2) # E: Revealed type is 'builtins.float'
184+
185+
[case testWalrus]
186+
if (a := 2):
187+
reveal_type(a) # E: Revealed type is 'builtins.int'
188+
189+
while (b := "x"):
190+
reveal_type(b) # E: Revealed type is 'builtins.str'
191+
192+
def f(x: int = (c := 4)) -> None:
193+
if (a := 2):
194+
reveal_type(a) # E: Revealed type is 'builtins.int'
195+
196+
while (b := "x"):
197+
reveal_type(b) # E: Revealed type is 'builtins.str'
198+
199+
x = (y := 1) + (z := 2)
200+
reveal_type(x) # E: Revealed type is 'builtins.int'
201+
reveal_type(y) # E: Revealed type is 'builtins.int'
202+
reveal_type(z) # E: Revealed type is 'builtins.int'
203+
204+
l = [y2 := 1, y2 + 2, y2 + 3]
205+
reveal_type(y2) # E: Revealed type is 'builtins.int'
206+
reveal_type(l) # E: Revealed type is 'builtins.list[builtins.int*]'
207+
208+
filtered_data = [y3 for x in l if (y3 := a) is not None]
209+
reveal_type(filtered_data) # E: Revealed type is 'builtins.list[builtins.int*]'
210+
# TODO this should be valid: https://www.python.org/dev/peps/pep-0572/#scope-of-the-target
211+
y3 # E: Name 'y3' is not defined
212+
213+
# https://www.python.org/dev/peps/pep-0572/#exceptional-cases
214+
(y4 := 3)
215+
reveal_type(y4) # E: Revealed type is 'builtins.int'
216+
217+
y5 = (y6 := 3)
218+
reveal_type(y5) # E: Revealed type is 'builtins.int'
219+
reveal_type(y6) # E: Revealed type is 'builtins.int'
220+
221+
f(x=(y7 := 3))
222+
reveal_type(y7) # E: Revealed type is 'builtins.int'
223+
224+
reveal_type((lambda: (y8 := 3) and y8)()) # E: Revealed type is 'builtins.int'
225+
226+
y7 = 1.0 # E: Incompatible types in assignment (expression has type "float", variable has type "int")
227+
if y7 := "x": # E: Incompatible types in assignment (expression has type "str", variable has type "int")
228+
pass
229+
230+
reveal_type(c) # E: Revealed type is 'builtins.int'
231+
232+
[builtins fixtures/f_string.pyi]

0 commit comments

Comments
 (0)