diff --git a/stdlib/distutils/command/check.pyi b/stdlib/distutils/command/check.pyi index cdbe40fff71d..3644c401b2ab 100644 --- a/stdlib/distutils/command/check.pyi +++ b/stdlib/distutils/command/check.pyi @@ -6,7 +6,9 @@ from ..cmd import Command _Reporter: TypeAlias = Any # really docutils.utils.Reporter # Only defined if docutils is installed. -class SilentReporter(_Reporter): +# Depends on a third-party stub. Since distutils is deprecated anyway, +# it's easier to just suppress the "any subclassing" error. +class SilentReporter(_Reporter): # type: ignore[misc] messages: Any def __init__( self, diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index 12ce2d2c78aa..f0345c903a3b 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -101,6 +101,8 @@ class _CallList(list[_Call]): class Base: def __init__(self, *args: Any, **kwargs: Any) -> None: ... +# We subclass with "Any" because mocks are explicitly designed to stand in for other types, +# something that can't be expressed with our static type system. class NonCallableMock(Base, Any): def __new__(__cls, *args: Any, **kw: Any) -> Self: ... def __init__( diff --git a/stubs/Pillow/PIL/ImageQt.pyi b/stubs/Pillow/PIL/ImageQt.pyi index 434ba4d7e22e..6eb6287327dc 100644 --- a/stubs/Pillow/PIL/ImageQt.pyi +++ b/stubs/Pillow/PIL/ImageQt.pyi @@ -3,7 +3,10 @@ from typing_extensions import Literal, TypeAlias from .Image import Image -_QImage: TypeAlias = Any # imported from either of {PyQt6,PySide6,PyQt5,PySide2}.QtGui +# imported from either of {PyQt6,PySide6,PyQt5,PySide2}.QtGui +# These are way too complex, with 4 different possible sources (2 deprecated) +# And we don't want to force the user to install PyQt or Pyside when they may not even use it. +_QImage: TypeAlias = Any _QPixmap: TypeAlias = Any qt_versions: Any @@ -15,7 +18,7 @@ def fromqimage(im: ImageQt | _QImage) -> Image: ... def fromqpixmap(im: ImageQt | _QImage) -> Image: ... def align8to32(bytes: bytes, width: int, mode: Literal["1", "L", "P"]) -> bytes: ... -class ImageQt(_QImage): +class ImageQt(_QImage): # type: ignore[misc] def __init__(self, im: Image) -> None: ... def toqimage(im: Image) -> ImageQt: ... diff --git a/stubs/SQLAlchemy/sqlalchemy/orm/decl_api.pyi b/stubs/SQLAlchemy/sqlalchemy/orm/decl_api.pyi index 8938a45ad691..c54ea44d0485 100644 --- a/stubs/SQLAlchemy/sqlalchemy/orm/decl_api.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/orm/decl_api.pyi @@ -13,7 +13,7 @@ _DeclT = TypeVar("_DeclT", bound=type[_DeclarativeBase]) # Dynamic class as created by registry.generate_base() via DeclarativeMeta # or another metaclass. This class does not exist at runtime. -class _DeclarativeBase(Any): # super classes are dynamic +class _DeclarativeBase(Any): # type: ignore[misc] # super classes are dynamic registry: ClassVar[registry] metadata: ClassVar[MetaData] __abstract__: ClassVar[bool] diff --git a/stubs/mock/mock/mock.pyi b/stubs/mock/mock/mock.pyi index 5fd3bdefd404..4de6ab88294a 100644 --- a/stubs/mock/mock/mock.pyi +++ b/stubs/mock/mock/mock.pyi @@ -81,7 +81,9 @@ class _CallList(list[_Call]): class Base: def __init__(self, *args: Any, **kwargs: Any) -> None: ... -class NonCallableMock(Base, Any): +# We subclass with "Any" because mocks are explicitly designed to stand in for other types, +# something that can't be expressed with our static type system. +class NonCallableMock(Base, Any): # type: ignore[misc] def __new__( cls: type[Self], spec: list[str] | object | type[object] | None = ..., diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 3f81e82e5378..651c0925baa3 100644 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -263,7 +263,6 @@ def run_mypy( # Stub completion is checked by pyright (--allow-*-defs) "--allow-untyped-defs", "--allow-incomplete-defs", - "--allow-subclassing-any", # See #9491 "--enable-error-code", "ignore-without-code", "--config-file",