unittest.case: tighter annotations for various assertions (#8077)

This commit is contained in:
Alex Waygood
2022-06-20 17:49:57 +01:00
committed by GitHub
parent bae4fd2209
commit 538621e91b
3 changed files with 108 additions and 58 deletions

View File

@@ -50,21 +50,23 @@ class SupportsAnext(Protocol[_T_co]):
# Comparison protocols
class SupportsDunderLT(Protocol):
def __lt__(self, __other: Any) -> bool: ...
class SupportsDunderLT(Protocol[_T_contra]):
def __lt__(self, __other: _T_contra) -> bool: ...
class SupportsDunderGT(Protocol):
def __gt__(self, __other: Any) -> bool: ...
class SupportsDunderGT(Protocol[_T_contra]):
def __gt__(self, __other: _T_contra) -> bool: ...
class SupportsDunderLE(Protocol):
def __le__(self, __other: Any) -> bool: ...
class SupportsDunderLE(Protocol[_T_contra]):
def __le__(self, __other: _T_contra) -> bool: ...
class SupportsDunderGE(Protocol):
def __ge__(self, __other: Any) -> bool: ...
class SupportsDunderGE(Protocol[_T_contra]):
def __ge__(self, __other: _T_contra) -> bool: ...
class SupportsAllComparisons(SupportsDunderLT, SupportsDunderGT, SupportsDunderLE, SupportsDunderGE, Protocol): ...
class SupportsAllComparisons(
SupportsDunderLT[Any], SupportsDunderGT[Any], SupportsDunderLE[Any], SupportsDunderGE[Any], Protocol
): ...
SupportsRichComparison: TypeAlias = SupportsDunderLT | SupportsDunderGT
SupportsRichComparison: TypeAlias = SupportsDunderLT[Any] | SupportsDunderGT[Any]
SupportsRichComparisonT = TypeVar("SupportsRichComparisonT", bound=SupportsRichComparison) # noqa: Y001
# Dunder protocols