mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-12 05:01:40 +08:00
Improve protocol return types (#7093)
* Dunder comparisons must return bool. * write() return type should be ignored. * Use custom comparison protocols in _operator.pyi
This commit is contained in:
@@ -38,16 +38,16 @@ class SupportsAnext(Protocol[_T_co]):
|
||||
# Comparison protocols
|
||||
|
||||
class SupportsDunderLT(Protocol):
|
||||
def __lt__(self, __other: Any) -> Any: ...
|
||||
def __lt__(self, __other: Any) -> bool: ...
|
||||
|
||||
class SupportsDunderGT(Protocol):
|
||||
def __gt__(self, __other: Any) -> Any: ...
|
||||
def __gt__(self, __other: Any) -> bool: ...
|
||||
|
||||
class SupportsDunderLE(Protocol):
|
||||
def __le__(self, __other: Any) -> Any: ...
|
||||
def __le__(self, __other: Any) -> bool: ...
|
||||
|
||||
class SupportsDunderGE(Protocol):
|
||||
def __ge__(self, __other: Any) -> Any: ...
|
||||
def __ge__(self, __other: Any) -> bool: ...
|
||||
|
||||
class SupportsAllComparisons(SupportsDunderLT, SupportsDunderGT, SupportsDunderLE, SupportsDunderGE, Protocol): ...
|
||||
|
||||
@@ -181,7 +181,7 @@ class SupportsNoArgReadline(Protocol[_T_co]):
|
||||
|
||||
# stable
|
||||
class SupportsWrite(Protocol[_T_contra]):
|
||||
def write(self, __s: _T_contra) -> Any: ...
|
||||
def write(self, __s: _T_contra) -> object: ...
|
||||
|
||||
ReadOnlyBuffer = bytes # stable
|
||||
# Anything that implements the read-write buffer interface.
|
||||
|
||||
Reference in New Issue
Block a user