diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index 47535499a9f2..3256461df907 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -102,7 +102,9 @@ class _CallList(list[_Call]): class Base: def __init__(self, *args: Any, **kwargs: Any) -> None: ... -class NonCallableMock(Base, Any): +# We subclass with "Any" because defining this and other mock classes exactly like the source +# causes many false positives with mypy and production code. +class NonCallableMock(Base, Any): # type: ignore[misc] def __new__(__cls: type[Self], *args: Any, **kw: Any) -> Self: ... def __init__( self, diff --git a/stubs/mock/mock/mock.pyi b/stubs/mock/mock/mock.pyi index 6e52136ce660..9c6e8dc2fac0 100644 --- a/stubs/mock/mock/mock.pyi +++ b/stubs/mock/mock/mock.pyi @@ -76,7 +76,9 @@ class _CallList(list[_Call]): class Base: def __init__(self, *args: Any, **kwargs: Any) -> None: ... -class NonCallableMock(Base, Any): +# We subclass with "Any" because defining this and other mock classes exactly like the source +# causes many false positives with mypy and production code. +class NonCallableMock(Base, Any): # type: ignore[misc] def __new__( cls: type[Self], spec: list[str] | object | type[object] | None = ...,