File tree Expand file tree Collapse file tree
its/ruling/src/test/resources/expected
python-checks/src/test/resources/checks
main/java/org/sonar/python/semantic
test/java/org/sonar/python/semantic Expand file tree Collapse file tree Original file line number Diff line number Diff line change 441149 ,
551169 ,
66],
7- 'project:mypy-0.782/mypy/options.py':[
8- 294 ,
9- ],
10- 'project:mypy-0.782/mypy/test/testgraph.py':[
11- 27 ,
12- 37 ,
13- 72 ,
14- 82 ,
15- 85 ,
16- ],
17- 'project:mypy-0.782/mypy/test/teststubgen.py':[
18- 47 ,
19- 49 ,
20- 49 ,
21- 67 ,
22- 69 ,
23- 69 ,
24- 106 ,
25- 110 ,
26- 172 ,
27- 182 ,
28- 187 ,
29- 190 ,
30- 195 ,
31- 200 ,
32- 204 ,
33- 205 ,
34- 207 ,
35- 210 ,
36- 213 ,
37- 216 ,
38- 220 ,
39- 224 ,
40- 228 ,
41- 234 ,
42- 240 ,
43- 244 ,
44- 248 ,
45- 251 ,
46- 254 ,
47- 258 ,
48- 263 ,
49- 271 ,
50- 275 ,
51- 280 ,
52- 288 ,
53- 611 ,
54- 614 ,
55- 618 ,
56- 623 ,
57- 627 ,
58- 634 ,
59- 634 ,
60- 646 ,
61- 646 ,
62- 647 ,
63- 647 ,
64- 657 ,
65- 657 ,
66- 658 ,
67- 658 ,
68- 671 ,
69- 671 ,
70- 672 ,
71- 672 ,
72- 684 ,
73- 684 ,
74- 685 ,
75- 685 ,
76- 699 ,
77- 699 ,
78- 700 ,
79- 700 ,
80- 714 ,
81- 714 ,
82- 715 ,
83- 715 ,
84- 730 ,
85- 730 ,
86- 731 ,
87- 731 ,
88- 748 ,
89- 748 ,
90- 749 ,
91- 749 ,
92- 762 ,
93- 762 ,
94- 763 ,
95- 763 ,
96- 778 ,
97- 778 ,
98- 779 ,
99- 779 ,
100- 798 ,
101- 798 ,
102- 805 ,
103- ],
104- 'project:mypy-0.782/mypy/test/testtypes.py':[
105- 407 ,
106- 407 ,
107- 420 ,
108- 423 ,
109- 446 ,
110- 446 ,
111- 449 ,
112- 449 ,
113- ],
114- 'project:mypy-0.782/mypy/treetransform.py':[
115- 130 ,
116- ],
1177'project:mypy-0.782/test-data/stdlib-samples/3.2/pprint.py':[
118867 ,
119971 ,
Original file line number Diff line number Diff line change 75753215 ,
76763217 ,
7777],
78- 'project:mypy-0.782/mypy/options.py':[
79- 286 ,
80- ],
8178'project:mypy-0.782/mypy/plugins/attrs.py':[
8279411 ,
8380413 ,
384381390 ,
385382753 ,
386383],
387- 'project:mypy-0.782/test-data/stdlib-samples/3.2/tempfile.py':[
388- 105 ,
389- ],
390384'project:mypy-0.782/test-data/stdlib-samples/3.2/test/test_random.py':[
39138579 ,
392386],
Original file line number Diff line number Diff line change @@ -172,6 +172,10 @@ class SomeMock(Mock): ...
172172 my_mock = SomeMock ()
173173 hex (my_mock ) # OK
174174
175+ def exception_for_object ():
176+ def foo (a : object ): ...
177+ foo ([])
178+
175179class StaticCallInsideClass :
176180 def my_method (a : int , b : str ): ...
177181 my_method (1 , "hello" ) # OK
Original file line number Diff line number Diff line change @@ -203,12 +203,18 @@ public boolean isOrExtends(String fullyQualifiedClassName) {
203203
204204 @ Override
205205 public boolean isOrExtends (ClassSymbol other ) {
206+ if ("object" .equals (other .fullyQualifiedName ())) {
207+ return true ;
208+ }
206209 // TODO there should be only 1 class with a given fullyQualifiedName when analyzing a python file
207210 return allSuperClasses (false ).stream ().anyMatch (c -> Objects .equals (c .fullyQualifiedName (), other .fullyQualifiedName ()));
208211 }
209212
210213 @ Override
211214 public boolean canBeOrExtend (String fullyQualifiedClassName ) {
215+ if ("object" .equals (fullyQualifiedClassName )) {
216+ return true ;
217+ }
212218 return allSuperClasses (true ).stream ().anyMatch (c -> c .fullyQualifiedName () != null && Objects .equals (fullyQualifiedClassName , c .fullyQualifiedName ()))
213219 || hasUnresolvedTypeHierarchy ();
214220 }
Original file line number Diff line number Diff line change 2929import org .sonar .plugins .python .api .tree .FileInput ;
3030import org .sonar .plugins .python .api .tree .Tree ;
3131import org .sonar .python .PythonTestUtils ;
32+ import org .sonar .python .types .TypeShed ;
3233
3334import static org .assertj .core .api .Assertions .assertThat ;
3435import static org .assertj .core .api .Assertions .assertThatThrownBy ;
@@ -156,6 +157,9 @@ public void isOrExtends() {
156157 assertThat (b .isOrExtends (a )).isFalse ();
157158 ClassSymbolImpl c = new ClassSymbolImpl ("c" , "mod2.c" );
158159 assertThat (a .isOrExtends (c )).isFalse ();
160+
161+ assertThat (new ClassSymbolImpl ("foo" , "foo" ).isOrExtends (TypeShed .typeShedClass ("object" ))).isTrue ();
162+ assertThat (a .isOrExtends (TypeShed .typeShedClass ("object" ))).isTrue ();
159163 }
160164
161165 @ Test
@@ -201,6 +205,9 @@ public void canBeOrExtend() {
201205 assertThat (d .canBeOrExtend ("mod1.a" )).isTrue ();
202206 assertThat (d .canBeOrExtend ("mod2.a" )).isTrue ();
203207 assertThat (d .canBeOrExtend ("mod3.a" )).isTrue ();
208+
209+ assertThat (new ClassSymbolImpl ("foo" , "foo" ).canBeOrExtend ("object" )).isTrue ();
210+ assertThat (a .canBeOrExtend ("object" )).isTrue ();
204211 }
205212
206213 @ Test
You can’t perform that action at this time.
0 commit comments