Skip to content

Commit cc53b15

Browse files
committed
Python: ObjectAPI to ValueAPI: ReturnValueIgnored: Reorganizes predicates
1 parent 09349f1 commit cc53b15

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

python/ql/src/Functions/ReturnValueIgnored.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ predicate returns_meaningful_value(FunctionValue f) {
5050
*/
5151

5252
f.isBuiltin() and
53-
f.(CallableObjectInternal).getAnInferredReturnType() != ClassValue::nonetype() and
53+
f.getAnInferredReturnType() != ClassValue::nonetype() and
5454
not f.getName() = "__import__"
5555
)
5656
}

python/ql/src/semmle/python/objects/Callables.qll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ abstract class CallableObjectInternal extends ObjectInternal {
4949

5050
/* Callables aren't iterable */
5151
override ObjectInternal getIterNext() { none() }
52-
53-
/** Gets a class that this function may return */
54-
ClassValue getAnInferredReturnType() {
55-
result = TBuiltinClassObject(this.(BuiltinFunctionObjectInternal).getReturnType())
56-
or
57-
result = TBuiltinClassObject(this.(BuiltinMethodObjectInternal).getReturnType())
58-
}
5952
}
6053

6154
/** Class representing Python functions */

python/ql/src/semmle/python/objects/ObjectAPI.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,13 @@ abstract class FunctionValue extends CallableValue {
581581
exists(Expr expr, AstNode origin | expr.pointsTo(this, origin) | not origin instanceof Lambda)
582582
)
583583
}
584+
585+
/** Gets a class that this function may return */
586+
ClassValue getAnInferredReturnType() {
587+
result = TBuiltinClassObject(this.(BuiltinFunctionObjectInternal).getReturnType())
588+
or
589+
result = TBuiltinClassObject(this.(BuiltinMethodObjectInternal).getReturnType())
590+
}
584591
}
585592

586593
/** Class representing Python functions */

0 commit comments

Comments
 (0)