Что я сделал до сих пор:
Код: Выделить всё
from typing import Any, Protocol
class SupportsLT(Protocol):
def __lt__(self, other: Any, /) -> bool: ...
class SupportsGT(Protocol):
def __gt__(self, other: Any, /) -> bool: ...
def quick_sort[T: SupportsLT | SupportsGT](seq: list[T]) -> list[T]:
if len(seq) list[T]:
if len(seq)
Подробнее здесь: [url]https://stackoverflow.com/questions/79237327/how-to-bound-typevar-correctly-to-protocol[/url]
Мобильная версия