From 72ee95bc0b2852eb591f6704e999907cb93f7817 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 6 Dec 2021 10:49:24 -0800 Subject: [PATCH] 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 --- stdlib/_operator.pyi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stdlib/_operator.pyi b/stdlib/_operator.pyi index a945a0be7..b8c71852c 100644 --- a/stdlib/_operator.pyi +++ b/stdlib/_operator.pyi @@ -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: ...