12
12
"""
13
13
14
14
15
- def run_pyright (codefile ):
15
+ def run_pyright (codefile : str ):
16
16
17
17
cmd = shlex .split (
18
18
f"pyright { codefile } " ,
@@ -33,14 +33,14 @@ def run_pyright(codefile):
33
33
34
34
35
35
def assert_pyright_output (
36
- codefile , expected_outputs = tuple (), expected_errors = tuple (), expected_status = 0
36
+ codefile : str , expected_outputs = tuple (), expected_errors = tuple (), expected_status = 0
37
37
):
38
38
output , error , status = run_pyright (codefile )
39
39
assert (
40
40
status == expected_status
41
41
), f"Status: { status } \n Output: { output } \n Error: { error } "
42
42
for ex_out in expected_outputs :
43
- assert ex_out in output
43
+ assert ex_out in output , f"Invalid output: \n { output } "
44
44
for ex_err in expected_errors :
45
45
assert ex_err in error
46
46
@@ -54,7 +54,7 @@ def assert_pyright_output(
54
54
{
55
55
"expected_status" : 1 ,
56
56
"expected_outputs" : [
57
- 'Argument of type "Literal[4]" cannot be assigned to parameter "a_string" of type "str"'
57
+ 'Argument of type "Literal[4]" cannot be assigned to parameter "a_string" of type "str | None "'
58
58
],
59
59
},
60
60
),
@@ -70,7 +70,7 @@ def assert_pyright_output(
70
70
"expected_status" : 1 ,
71
71
"expected_outputs" : [
72
72
'Argument of type "Literal[\' \' ]" cannot be assigned to parameter "a_number" '
73
- 'of type "int | float | Number"'
73
+ 'of type "int | float | Number | None "'
74
74
],
75
75
},
76
76
),
@@ -104,7 +104,7 @@ def assert_pyright_output(
104
104
"expected_status" : 1 ,
105
105
"expected_outputs" : [
106
106
'Argument of type "dict[Any, Any]" cannot be assigned to parameter "array_string" '
107
- 'of type "List [str] | Tuple[Unknown, ...]"'
107
+ 'of type "Sequence [str] | Tuple[Unknown, ...] | None "'
108
108
],
109
109
},
110
110
),
@@ -204,7 +204,7 @@ def assert_pyright_output(
204
204
"expected_status" : 1 ,
205
205
"expected_outputs" : [
206
206
'Argument of type "tuple[Literal[1], Literal[2]]" cannot be assigned '
207
- 'to parameter "a_tuple" of type "Tuple[int | float | Number, str]"'
207
+ 'to parameter "a_tuple" of type "Tuple[int | float | Number, str] | None "'
208
208
],
209
209
},
210
210
),
@@ -224,14 +224,16 @@ def assert_pyright_output(
224
224
"obj={}" ,
225
225
{
226
226
"expected_status" : 1 ,
227
- "expected_outputs" : ['"value " is required in "Obj"' ],
227
+ "expected_outputs" : ['"dict[Any, Any] " is incompatible with "Obj"' ],
228
228
},
229
229
),
230
230
(
231
231
"obj={'value': 'a', 'label': 1}" ,
232
232
{
233
233
"expected_status" : 1 ,
234
- "expected_outputs" : ['"Literal[1]" is incompatible with "str"' ],
234
+ "expected_outputs" : [
235
+ '"dict[str, str | int]" is incompatible with "Obj"'
236
+ ],
235
237
},
236
238
),
237
239
(
0 commit comments