Skip to content

Commit 42388b0

Browse files
committed
Python: ObjectAPI to ValueAPI: ReturnValueIgnored: Adds prototype version of getAnInferredReturnType
1 parent 7ce905a commit 42388b0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

python/ql/src/Functions/ReturnValueIgnored.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ predicate returns_meaningful_value(FunctionValue f) {
4242
or
4343
/* Is f a builtin function that returns something other than None?
4444
* Ignore __import__ as it is often called purely for side effects */
45-
f.isBuiltin() and f.getAnInferredReturnType() != theNoneType() and not f.getName() = "__import__"
45+
f.isBuiltin() and f.getAnInferredReturnType() != ClassValue::nonetype() and not f.getName() = "__import__"
4646
)
4747
}
4848

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,12 @@ abstract class FunctionValue extends CallableValue {
514514
predicate isOverriddenMethod() {
515515
exists(Value f | f.overrides(this))
516516
}
517+
518+
/** Gets a class that this function may return */
519+
ClassValue getAnInferredReturnType() {
520+
//result = this.(BuiltinCallable).getAReturnType()
521+
result = this.getScope().getAReturnValueFlowNode().pointsTo().getClass()
522+
}
517523
}
518524

519525
/** Class representing Python functions */

0 commit comments

Comments
 (0)