@@ -16,7 +16,9 @@ predicate is_unary_op(string name) {
16
16
name in [
17
17
"__del__" , "__repr__" , "__neg__" , "__pos__" , "__abs__" , "__invert__" , "__complex__" ,
18
18
"__int__" , "__float__" , "__long__" , "__oct__" , "__hex__" , "__str__" , "__index__" , "__enter__" ,
19
- "__hash__" , "__bool__" , "__nonzero__" , "__unicode__" , "__len__" , "__iter__" , "__reversed__"
19
+ "__hash__" , "__bool__" , "__nonzero__" , "__unicode__" , "__len__" , "__iter__" , "__reversed__" ,
20
+ "__aenter__" , "__aiter__" , "__anext__" , "__await__" , "__ceil__" , "__floor__" , "__trunc__" ,
21
+ "__length_hint__" , "__dir__" , "__bytes__"
20
22
]
21
23
}
22
24
@@ -28,17 +30,19 @@ predicate is_binary_op(string name) {
28
30
"__and__" , "__xor__" , "__or__" , "__ne__" , "__radd__" , "__rsub__" , "__rmul__" , "__rfloordiv__" ,
29
31
"__rdiv__" , "__rtruediv__" , "__rmod__" , "__rdivmod__" , "__rpow__" , "__rlshift__" , "__gt__" ,
30
32
"__rrshift__" , "__rand__" , "__rxor__" , "__ror__" , "__iadd__" , "__isub__" , "__imul__" ,
31
- "__ifloordiv__" , "__idiv__" , "__itruediv__" , "__ge__" , "__imod__" , "__idivmod__" , "__ipow__" ,
32
- "__ilshift__" , "__irshift__" , "__iand__" , "__ixor__" , "__ior__" , "__coerce__" , "__cmp__" ,
33
- "__rcmp__" , "__getattr___" , "__getattribute___"
33
+ "__ifloordiv__" , "__idiv__" , "__itruediv__" , "__ge__" , "__imod__" , "__ipow__" , "__ilshift__" ,
34
+ "__irshift__" , "__iand__" , "__ixor__" , "__ior__" , "__coerce__" , "__cmp__" , "__rcmp__" ,
35
+ "__getattr__" , "__getattribute__" , "__buffer__" , "__release_buffer__" , "__matmul__" ,
36
+ "__rmatmul__" , "__imatmul__" , "__missing__" , "__class_getitem__" , "__mro_entries__" ,
37
+ "__format__"
34
38
]
35
39
}
36
40
37
41
predicate is_ternary_op ( string name ) {
38
- name in [ "__setattr__" , "__set__" , "__setitem__" , "__getslice__" , "__delslice__" ]
42
+ name in [ "__setattr__" , "__set__" , "__setitem__" , "__getslice__" , "__delslice__" , "__set_name__" ]
39
43
}
40
44
41
- predicate is_quad_op ( string name ) { name = "__setslice__" or name = "__exit__" }
45
+ predicate is_quad_op ( string name ) { name in [ "__setslice__" , "__exit__" , "__aexit__" ] }
42
46
43
47
int argument_count ( string name ) {
44
48
is_unary_op ( name ) and result = 1
@@ -97,6 +101,27 @@ predicate incorrect_pow(
97
101
)
98
102
}
99
103
104
+ predicate incorrect_round (
105
+ Function func , string message , boolean show_counts , boolean is_unused_default
106
+ ) {
107
+ exists ( int correction | correction = staticmethod_correction ( func ) |
108
+ func .getMaxPositionalArguments ( ) < 1 - correction and
109
+ message = "Too few parameters" and
110
+ show_counts = true and
111
+ is_unused_default = false
112
+ or
113
+ func .getMinPositionalArguments ( ) > 2 - correction and
114
+ message = "Too many parameters" and
115
+ show_counts = true and
116
+ is_unused_default = false
117
+ or
118
+ func .getMinPositionalArguments ( ) = 2 - correction and
119
+ message = "Second parameter to __round__ should have a default value" and
120
+ show_counts = false and
121
+ is_unused_default = false
122
+ )
123
+ }
124
+
100
125
predicate incorrect_get (
101
126
Function func , string message , boolean show_counts , boolean is_unused_default
102
127
) {
@@ -160,6 +185,8 @@ where
160
185
or
161
186
incorrect_get ( f .getScope ( ) , message , show_counts , show_unused_defaults ) and name = "__get__"
162
187
or
188
+ incorrect_round ( f .getScope ( ) , message , show_counts , show_unused_defaults ) and
189
+ name = "__round__"
163
190
) and
164
191
not isLikelyPlaceholderFunction ( f .getScope ( ) ) and
165
192
show_unused_defaults = false and
0 commit comments