A class defines some of __lt__, __le__, __gt__ and __ge__ but not all, and is not marked total_ordering

tx0/python:incomplete-orderingstrictwarningbug

What it finds

Python does not derive the missing comparisons from the ones a class defines: with only __lt__, a <= b raises TypeError unless the other operand handles it. Defining all four, or decorating the class with functools.total_ordering, which fills in the rest, makes every comparison work. Classes with bases, which may define the others, are not checked.

From the rule's source, incomplete_ordering.rs.

Example from the rule's tests
import functools  class Version:tx0 reports: this class defines only __lt__ of the four ordering methods    def __lt__(self, other):        return True  @functools.total_orderingclass Ordered:    def __lt__(self, other):        return True  class Full:    def __lt__(self, other):        return True     def __le__(self, other):        return True     def __gt__(self, other):        return True     def __ge__(self, other):        return True
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:incomplete-ordering" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

# tx0: ignore[tx0/python:incomplete-ordering] reason="..."

tx0 explain tx0/python:incomplete-ordering shows the same in the terminal. Found a false positive? Report it.