mirror of https://github.com/astral-sh/ruff
annotate tests with expected results, add module-level error case
This commit is contained in:
parent
5469fee677
commit
d233adf92b
|
|
@ -1,27 +1,30 @@
|
|||
a: int = 1
|
||||
def f1():
|
||||
global a
|
||||
a: str = "foo"
|
||||
a: str = "foo" # error
|
||||
|
||||
b: int = 1
|
||||
def outer():
|
||||
def inner():
|
||||
global b
|
||||
b: str = "nested"
|
||||
b: str = "nested" # error
|
||||
|
||||
c: int = 1
|
||||
def f2():
|
||||
global c
|
||||
c: list[str] = []
|
||||
c: list[str] = [] # error
|
||||
|
||||
d: int = 1
|
||||
def f3():
|
||||
global d
|
||||
d: str
|
||||
d: str # error
|
||||
|
||||
e: int = 1
|
||||
def f4():
|
||||
e: str = "happy"
|
||||
e: str = "happy" # okay
|
||||
|
||||
global f
|
||||
f: int = 1
|
||||
f: int = 1 # okay
|
||||
|
||||
g: int = 1
|
||||
global g # error
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ invalid-syntax: annotated name `a` can't be global
|
|||
|
|
||||
2 | def f1():
|
||||
3 | global a
|
||||
4 | a: str = "foo"
|
||||
4 | a: str = "foo" # error
|
||||
| ^
|
||||
5 |
|
||||
6 | b: int = 1
|
||||
|
|
@ -17,7 +17,7 @@ invalid-syntax: annotated name `b` can't be global
|
|||
|
|
||||
8 | def inner():
|
||||
9 | global b
|
||||
10 | b: str = "nested"
|
||||
10 | b: str = "nested" # error
|
||||
| ^
|
||||
11 |
|
||||
12 | c: int = 1
|
||||
|
|
@ -28,7 +28,7 @@ invalid-syntax: annotated name `c` can't be global
|
|||
|
|
||||
13 | def f2():
|
||||
14 | global c
|
||||
15 | c: list[str] = []
|
||||
15 | c: list[str] = [] # error
|
||||
| ^
|
||||
16 |
|
||||
17 | d: int = 1
|
||||
|
|
@ -39,7 +39,7 @@ invalid-syntax: annotated name `d` can't be global
|
|||
|
|
||||
18 | def f3():
|
||||
19 | global d
|
||||
20 | d: str
|
||||
20 | d: str # error
|
||||
| ^
|
||||
21 |
|
||||
22 | e: int = 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue