operator: make Protocol parameters positional-only (#6519)

pyanalyze checks parameter names for protocols strictly, so `float` didn't match these protocols.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Jelle Zijlstra
2021-12-06 10:49:24 -08:00
committed by GitHub
parent 6b2218846c
commit 72ee95bc0b

View File

@@ -37,17 +37,19 @@ class _SupportsPos(Protocol[_T_co]):
# Different to _typeshed.SupportsLessThan
class _SupportsLT(Protocol):
def __lt__(self, other: Any) -> Any: ...
def __lt__(self, __other: Any) -> Any: ...
class _SupportsGT(Protocol):
def __gt__(self, other: Any) -> Any: ...
def __gt__(self, __other: Any) -> Any: ...
class _SupportsLE(Protocol):
def __le__(self, other: Any) -> Any: ...
def __le__(self, __other: Any) -> Any: ...
class _SupportsGE(Protocol):
def __ge__(self, other: Any) -> Any: ...
def __ge__(self, __other: Any) -> Any: ...
# We get false-positive errors if e.g. `lt` does not have the same signature as `le`,
# so a broad union type is required for all four comparison methods
_SupportsComparison = Union[_SupportsLE, _SupportsGE, _SupportsGT, _SupportsLT]
def lt(__a: _SupportsComparison, __b: _SupportsComparison) -> Any: ...