File tree Expand file tree Collapse file tree 2 files changed +103
-0
lines changed
plugins/tools/pyrefly/test Expand file tree Collapse file tree 2 files changed +103
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "$schema" : " https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json" ,
3+ "version" : " 2.1.0" ,
4+ "runs" : [
5+ {
6+ "results" : [
7+ {
8+ "level" : " error" ,
9+ "locations" : [
10+ {
11+ "physicalLocation" : {
12+ "artifactLocation" : {
13+ "uri" : " src/test_file.py"
14+ },
15+ "region" : {
16+ "startLine" : 12 ,
17+ "startColumn" : 24
18+ }
19+ }
20+ }
21+ ],
22+ "message" : {
23+ "text" : " Argument `Literal['one']` is not assignable to parameter `a` with type `int` in function `add_numbers`"
24+ },
25+ "ruleId" : " bad-argument-type"
26+ },
27+ {
28+ "level" : " error" ,
29+ "locations" : [
30+ {
31+ "physicalLocation" : {
32+ "artifactLocation" : {
33+ "uri" : " src/test_file.py"
34+ },
35+ "region" : {
36+ "startLine" : 14 ,
37+ "startColumn" : 25
38+ }
39+ }
40+ }
41+ ],
42+ "message" : {
43+ "text" : " Function declared to return `int` but is missing an explicit `return`"
44+ },
45+ "ruleId" : " bad-return"
46+ },
47+ {
48+ "level" : " error" ,
49+ "locations" : [
50+ {
51+ "physicalLocation" : {
52+ "artifactLocation" : {
53+ "uri" : " src/test_file.py"
54+ },
55+ "region" : {
56+ "startLine" : 20 ,
57+ "startColumn" : 12
58+ }
59+ }
60+ }
61+ ],
62+ "message" : {
63+ "text" : " Returned type `Literal[123]` is not assignable to declared return type `str`"
64+ },
65+ "ruleId" : " bad-return"
66+ }
67+ ],
68+ "tool" : {
69+ "driver" : {
70+ "informationUri" : " https://pyrefly.org" ,
71+ "name" : " Pyrefly" ,
72+ "rules" : null ,
73+ "version" : " 0.22.0"
74+ }
75+ }
76+ }
77+ ]
78+ }
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ # -*- coding: utf-8 -*-
3+ """
4+ Test file for pyrefly analysis
5+ """
6+
7+ def add_numbers (a : int , b : int ) -> int :
8+ return a + b
9+
10+ def call_with_wrong_type ():
11+ # This should trigger a type error in pyrefly
12+ return add_numbers ("one" , 2 )
13+
14+ def missing_return () -> int :
15+ # This function is missing a return statement
16+ pass
17+
18+ def wrong_return_type () -> str :
19+ # This function returns an int instead of a str
20+ return 123
21+
22+ if __name__ == "__main__" :
23+ call_with_wrong_type ()
24+ missing_return ()
25+ wrong_return_type ()
You can’t perform that action at this time.
0 commit comments