I've got a list of elements of a dataclass X (marked order=True) and pass them to max(). I get a type checking warning in my IDE: Expected type 'Iterable' (matched generic type 'Iterable[SupportsLessThanT]'), got 'List[X]' instead. How can I avoid this error? What do I have to declare to make the warning disappear? (I don't want to suppress it of course.)
I thought because the class X is marked as order=True it would be obviously sortable, so that passing it to max() should be no problem. But apparently this isn't known to the type system.
@dataclass(frozen=True, order=True)
class X:
value: int
def f(xs: List[X]) -> None:
q = max(xs) # here's the above mentioned type checking warning
I tried inheriting various things in the class X but nothing helped.
Is there a supposed way to deal with this or do I have to ignore the warning?