@@ -14,6 +14,8 @@ private predicate isMetaclass(Class c) {
14
14
/** Holds if `f` is a class method. */
15
15
private predicate isClassMethod ( Function f ) {
16
16
f .getADecorator ( ) = API:: builtin ( "classmethod" ) .asSource ( ) .asExpr ( )
17
+ or
18
+ f .getName ( ) in [ "__new__" , "__init_subclass__" , "__metaclass__" , "__class_getitem__" ]
17
19
}
18
20
19
21
/** Holds if `f` is a static method. */
@@ -37,8 +39,7 @@ predicate shouldBeSelf(Function f, Class c) {
37
39
methodOfClass ( f , c ) and
38
40
not isStaticMethod ( f ) and
39
41
not isClassMethod ( f ) and
40
- not f .getName ( ) in [ "__new__" , "__init_subclass__" , "__metaclass__" , "__class_getitem__" ] and
41
- isMetaclass ( c ) and
42
+ not isMetaclass ( c ) and
42
43
not isZopeInterface ( c )
43
44
}
44
45
@@ -47,9 +48,9 @@ predicate shouldBeCls(Function f, Class c) {
47
48
methodOfClass ( f , c ) and
48
49
not isStaticMethod ( f ) and
49
50
(
50
- isClassMethod ( f )
51
+ isClassMethod ( f ) and not isMetaclass ( c )
51
52
or
52
- f . getName ( ) in [ "__new__" , "__init_subclass__" , "__metaclass__" , "__class_getitem__" ]
53
+ isMetaclass ( c ) and not isClassMethod ( f )
53
54
)
54
55
}
55
56
@@ -68,12 +69,12 @@ predicate firstArgNamedCls(Function f) {
68
69
69
70
/** Holds if the first parameter of `f` should be named `self`, but isn't. */
70
71
predicate firstArgShouldBeNamedSelfAndIsnt ( Function f ) {
71
- exists ( Class c | shouldBeSelf ( f , c ) ) and
72
+ shouldBeSelf ( f , _ ) and
72
73
not firstArgNamedSelf ( f )
73
74
}
74
75
75
76
/** Holds if the first parameter of `f` should be named `cls`, but isn't. */
76
77
predicate firstArgShouldBeNamedClsAndIsnt ( Function f ) {
77
- exists ( Class c | shouldBeCls ( f , c ) ) and
78
+ shouldBeCls ( f , _ ) and
78
79
not firstArgNamedCls ( f )
79
80
}
0 commit comments