Add mypy error codes to '# type: ignore' comments (#6379)

This commit is contained in:
Akuli
2021-11-26 08:07:56 +02:00
committed by GitHub
parent 1278fa86e2
commit a5bc1e037f
74 changed files with 218 additions and 202 deletions

View File

@@ -81,7 +81,7 @@ class TestCase:
def assertLess(self, a: Any, b: Any, msg: Any = ...) -> None: ...
def assertLessEqual(self, a: Any, b: Any, msg: Any = ...) -> None: ...
@overload
def assertRaises( # type: ignore
def assertRaises( # type: ignore[misc]
self,
expected_exception: Type[BaseException] | Tuple[Type[BaseException], ...],
callable: Callable[..., Any],
@@ -91,7 +91,7 @@ class TestCase:
@overload
def assertRaises(self, expected_exception: Type[_E] | Tuple[Type[_E], ...], msg: Any = ...) -> _AssertRaisesContext[_E]: ...
@overload
def assertRaisesRegex( # type: ignore
def assertRaisesRegex( # type: ignore[misc]
self,
expected_exception: Type[BaseException] | Tuple[Type[BaseException], ...],
expected_regex: str | bytes | Pattern[str] | Pattern[bytes],
@@ -107,13 +107,13 @@ class TestCase:
msg: Any = ...,
) -> _AssertRaisesContext[_E]: ...
@overload
def assertWarns( # type: ignore
def assertWarns( # type: ignore[misc]
self, expected_warning: Type[Warning] | Tuple[Type[Warning], ...], callable: Callable[..., Any], *args: Any, **kwargs: Any
) -> None: ...
@overload
def assertWarns(self, expected_warning: Type[Warning] | Tuple[Type[Warning], ...], msg: Any = ...) -> _AssertWarnsContext: ...
@overload
def assertWarnsRegex( # type: ignore
def assertWarnsRegex( # type: ignore[misc]
self,
expected_warning: Type[Warning] | Tuple[Type[Warning], ...],
expected_regex: str | bytes | Pattern[str] | Pattern[bytes],
@@ -195,7 +195,7 @@ class TestCase:
def assert_(self, expr: bool, msg: Any = ...) -> None: ...
def failIf(self, expr: bool, msg: Any = ...) -> None: ...
@overload
def failUnlessRaises( # type: ignore
def failUnlessRaises( # type: ignore[misc]
self,
exception: Type[BaseException] | Tuple[Type[BaseException], ...],
callable: Callable[..., Any] = ...,
@@ -215,7 +215,7 @@ class TestCase:
def assertRegexpMatches(self, text: AnyStr, regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ...
def assertNotRegexpMatches(self, text: AnyStr, regex: AnyStr | Pattern[AnyStr], msg: Any = ...) -> None: ...
@overload
def assertRaisesRegexp( # type: ignore
def assertRaisesRegexp( # type: ignore[misc]
self,
exception: Type[BaseException] | Tuple[Type[BaseException], ...],
expected_regex: str | bytes | Pattern[str] | Pattern[bytes],

View File

@@ -71,7 +71,7 @@ class _MockIter:
class Base:
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class NonCallableMock(Base, Any): # type: ignore
class NonCallableMock(Base, Any):
def __new__(__cls, *args: Any, **kw: Any) -> NonCallableMock: ...
def __init__(
self,
@@ -210,7 +210,7 @@ class _patcher:
# Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],
# but that's impossible with the current type system.
@overload
def __call__( # type: ignore
def __call__( # type: ignore[misc]
self,
target: Any,
new: _T,
@@ -222,7 +222,7 @@ class _patcher:
**kwargs: Any,
) -> _patch[_T]: ...
@overload
def __call__( # type: ignore
def __call__(
self,
target: Any,
*,
@@ -235,7 +235,7 @@ class _patcher:
) -> _patch[MagicMock | AsyncMock]: ...
else:
@overload
def __call__( # type: ignore
def __call__( # type: ignore[misc]
self,
target: Any,
new: _T,
@@ -247,7 +247,7 @@ class _patcher:
**kwargs: Any,
) -> _patch[_T]: ...
@overload
def __call__( # type: ignore
def __call__(
self,
target: Any,
*,
@@ -260,7 +260,7 @@ class _patcher:
) -> _patch[MagicMock]: ...
if sys.version_info >= (3, 8):
@overload
def object( # type: ignore
def object( # type: ignore[misc]
self,
target: Any,
attribute: str,
@@ -273,7 +273,7 @@ class _patcher:
**kwargs: Any,
) -> _patch[_T]: ...
@overload
def object( # type: ignore
def object(
self,
target: Any,
attribute: str,
@@ -287,7 +287,7 @@ class _patcher:
) -> _patch[MagicMock | AsyncMock]: ...
else:
@overload
def object( # type: ignore
def object( # type: ignore[misc]
self,
target: Any,
attribute: str,
@@ -300,7 +300,7 @@ class _patcher:
**kwargs: Any,
) -> _patch[_T]: ...
@overload
def object( # type: ignore
def object(
self,
target: Any,
attribute: str,

View File

@@ -11,4 +11,4 @@ def removeResult(result: unittest.result.TestResult) -> bool: ...
@overload
def removeHandler(method: None = ...) -> None: ...
@overload
def removeHandler(method: Callable[_P, _T]) -> Callable[_P, _T]: ... # type: ignore
def removeHandler(method: Callable[_P, _T]) -> Callable[_P, _T]: ... # type: ignore[misc]