Skip to content

Commit

Permalink
Fix typeshed regression in unittest (python#13092)
Browse files Browse the repository at this point in the history
Fixes python#13090

Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
  • Loading branch information
2 people authored and Gobot1234 committed Aug 12, 2022
1 parent b6d4016 commit 656dfc7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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

0 comments on commit 656dfc7

Please sign in to comment.