Python: Modernise the py/not-named-cls query.

This commit is contained in:
Rasmus Wriedt Larsen
2019-09-26 12:57:08 +02:00
parent 47a094239c
commit 3f974fbc14
2 changed files with 7 additions and 2 deletions

View File

@@ -23,13 +23,13 @@ predicate first_arg_cls(Function f) {
}
predicate is_type_method(Function f) {
exists(ClassObject c | c.getPyClass() = f.getScope() and c.getASuperType() = theTypeType())
exists(ClassValue c | c.getScope() = f.getScope() and c.getASuperType() = ClassValue::type())
}
predicate classmethod_decorators_only(Function f) {
forall(Expr decorator |
decorator = f.getADecorator() |
((Name) decorator).getId() = "classmethod")
decorator.(Name).getId() = "classmethod")
}
from Function f, string message

View File

@@ -560,6 +560,11 @@ module ClassValue {
result = TBuiltinClassObject(Builtin::special("FunctionType"))
}
/** Get the `ClassValue` for the `type` class. */
ClassValue type() {
result = TType()
}
/** Get the `ClassValue` for the class of builtin functions. */
ClassValue builtinFunction() {
result = Value::named("len").getClass()