Skip to content

Commit 843a6c8

Browse files
Remove total order check from equals not equals (doesn't make sense there; total order doesn't define eq or ne methods at all)
1 parent 083d258 commit 843a6c8

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

python/ql/src/Classes/Comparisons/Comparisons.qll

Lines changed: 0 additions & 12 deletions
This file was deleted.

python/ql/src/Classes/Comparisons/EqualsOrNotEquals.ql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313

1414
import python
15-
import Comparisons
1615
import semmle.python.dataflow.new.internal.DataFlowDispatch
1716
import Classes.Equality
1817

@@ -33,8 +32,6 @@ predicate missingEquality(Class cls, Function defined, string missing) {
3332
}
3433

3534
from Class cls, Function defined, string missing
36-
where
37-
not totalOrdering(cls) and
38-
missingEquality(cls, defined, missing)
35+
where missingEquality(cls, defined, missing)
3936
select cls, "This class implements $@, but does not implement " + missing + ".", defined,
4037
defined.getName()

python/ql/src/Classes/Comparisons/IncompleteOrdering.ql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
import python
1515
import semmle.python.dataflow.new.internal.DataFlowDispatch
1616
import semmle.python.ApiGraphs
17-
import Comparisons
17+
18+
/** Holds if `cls` has the `functools.total_ordering` decorator. */
19+
predicate totalOrdering(Class cls) {
20+
API::moduleImport("functools")
21+
.getMember("total_ordering")
22+
.asSource()
23+
.flowsTo(DataFlow::exprNode(cls.getADecorator()))
24+
}
1825

1926
predicate definesStrictOrdering(Class cls, Function meth) {
2027
meth = cls.getMethod("__lt__")

0 commit comments

Comments
 (0)