mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-15 16:27:08 +08:00
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:
@@ -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: ...
|
||||
|
||||
Reference in New Issue
Block a user