Skip to content

Fix typeshed regression in unittest #13092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mypy/typeshed/stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class SupportsRAdd(Protocol[_T_contra, _T_co]):
class SupportsSub(Protocol[_T_contra, _T_co]):
def __sub__(self, __x: _T_contra) -> _T_co: ...

class SupportsRSub(Protocol[_T_contra, _T_co]):
def __rsub__(self, __x: _T_contra) -> _T_co: ...

class SupportsDivMod(Protocol[_T_contra, _T_co]):
def __divmod__(self, __other: _T_contra) -> _T_co: ...

Expand Down
20 changes: 19 additions & 1 deletion mypy/typeshed/stdlib/unittest/case.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import sys
import unittest.result
from _typeshed import Self, SupportsDunderGE, SupportsSub
from _typeshed import Self, SupportsDunderGE, SupportsRSub, SupportsSub
from collections.abc import Callable, Container, Iterable, Mapping, Sequence, Set as AbstractSet
from contextlib import AbstractContextManager
from types import TracebackType
Expand Down Expand Up @@ -196,6 +196,15 @@ class TestCase:
delta: None = ...,
) -> None: ...
@overload
def assertAlmostEqual(
self,
first: _T,
second: SupportsRSub[_T, SupportsAbs[SupportsRound[object]]],
places: int | None = ...,
msg: Any = ...,
delta: None = ...,
) -> None: ...
@overload
def assertNotAlmostEqual(self, first: _S, second: _S, places: None, msg: Any, delta: _SupportsAbsAndDunderGE) -> None: ...
@overload
def assertNotAlmostEqual(
Expand All @@ -210,6 +219,15 @@ class TestCase:
msg: Any = ...,
delta: None = ...,
) -> None: ...
@overload
def assertNotAlmostEqual(
self,
first: _T,
second: SupportsRSub[_T, SupportsAbs[SupportsRound[object]]],
places: int | None = ...,
msg: Any = ...,
delta: None = ...,
) -> None: ...
def assertRegex(self, text: AnyStr, expected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ...
def assertNotRegex(self, text: AnyStr, unexpected_regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ...
def assertCountEqual(self, first: Iterable[Any], second: Iterable[Any], msg: Any = ...) -> None: ...
Expand Down