annotate tests with expected results, add module-level error case

This commit is contained in:
Brent Westbrook 2025-12-08 14:55:03 -05:00
parent 5469fee677
commit d233adf92b
No known key found for this signature in database
2 changed files with 13 additions and 10 deletions

View File

@ -1,27 +1,30 @@
a: int = 1 a: int = 1
def f1(): def f1():
global a global a
a: str = "foo" a: str = "foo" # error
b: int = 1 b: int = 1
def outer(): def outer():
def inner(): def inner():
global b global b
b: str = "nested" b: str = "nested" # error
c: int = 1 c: int = 1
def f2(): def f2():
global c global c
c: list[str] = [] c: list[str] = [] # error
d: int = 1 d: int = 1
def f3(): def f3():
global d global d
d: str d: str # error
e: int = 1 e: int = 1
def f4(): def f4():
e: str = "happy" e: str = "happy" # okay
global f global f
f: int = 1 f: int = 1 # okay
g: int = 1
global g # error

View File

@ -6,7 +6,7 @@ invalid-syntax: annotated name `a` can't be global
| |
2 | def f1(): 2 | def f1():
3 | global a 3 | global a
4 | a: str = "foo" 4 | a: str = "foo" # error
| ^ | ^
5 | 5 |
6 | b: int = 1 6 | b: int = 1
@ -17,7 +17,7 @@ invalid-syntax: annotated name `b` can't be global
| |
8 | def inner(): 8 | def inner():
9 | global b 9 | global b
10 | b: str = "nested" 10 | b: str = "nested" # error
| ^ | ^
11 | 11 |
12 | c: int = 1 12 | c: int = 1
@ -28,7 +28,7 @@ invalid-syntax: annotated name `c` can't be global
| |
13 | def f2(): 13 | def f2():
14 | global c 14 | global c
15 | c: list[str] = [] 15 | c: list[str] = [] # error
| ^ | ^
16 | 16 |
17 | d: int = 1 17 | d: int = 1
@ -39,7 +39,7 @@ invalid-syntax: annotated name `d` can't be global
| |
18 | def f3(): 18 | def f3():
19 | global d 19 | global d
20 | d: str 20 | d: str # error
| ^ | ^
21 | 21 |
22 | e: int = 1 22 | e: int = 1