File tree Expand file tree Collapse file tree 4 files changed +7
-36
lines changed
its/ruling/src/test/resources/expected
python-checks/src/test/resources/checks
main/java/org/sonar/python/types
test/java/org/sonar/python/types Expand file tree Collapse file tree 4 files changed +7
-36
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -66,10 +66,12 @@ def member_access():
66
66
my_callable .non_callable = 42
67
67
my_callable .non_callable () # FN
68
68
69
- def types_from_typeshed ():
69
+ def types_from_typeshed (foo ):
70
70
from math import acos
71
+ from functools import wraps
71
72
acos (42 )() # Noncompliant {{Fix this call; this expression has type float and it is not callable.}}
72
73
# ^^^^^^^^
74
+ wraps (func )(foo ) # OK, wraps returns a Callable
73
75
74
76
def with_metaclass ():
75
77
class Factory : ...
Original file line number Diff line number Diff line change @@ -156,8 +156,10 @@ public static InferredType fromTypeshedProtobuf(SymbolsProtos.Type type) {
156
156
String typeName = type .getFullyQualifiedName ();
157
157
return typeName .isEmpty () ? anyType () : runtimeType (TypeShed .symbolWithFQN (typeName ));
158
158
case TYPE_ALIAS :
159
- case CALLABLE :
160
159
return fromTypeshedProtobuf (type .getArgs (0 ));
160
+ case CALLABLE :
161
+ // this should be handled as a function type - see SONARPY-953
162
+ return anyType ();
161
163
case UNION :
162
164
return union (type .getArgsList ().stream ().map (InferredTypes ::fromTypeshedProtobuf ));
163
165
case TUPLE :
Original file line number Diff line number Diff line change @@ -359,6 +359,7 @@ public void test_type_from_protobuf() throws TextFormat.ParseException {
359
359
"fully_qualified_name: \" mod.t\" "
360
360
))
361
361
.isEqualTo (InferredTypes .or (STR , INT ));
362
+ assertThat (protobufType ("kind: CALLABLE" )).isEqualTo (anyType ());
362
363
}
363
364
364
365
private static InferredType protobufType (String protobuf ) throws TextFormat .ParseException {
You can’t perform that action at this time.
0 commit comments