PyQt6 6.12.1 stubs: typing.Self breaks type checking across all modules

Randy Northrup randy.northrup at gmail.com
Mon Nov 16 00:45:10 GMT 2026


Hi Phil,

Adding to Dragan's and Veronica's reports: mypy shows the same, and a few
more places where typing.Self doesn't fit.

With PyQt6 6.12.1, mypy 2.4.1 --strict on this file:

    from PyQt6.QtCore import QObject, pyqtSignal


    class A(QObject):
        changed = pyqtSignal(int)


    class B(QObject):
        def watch(self, a: A) -> None:
            a.installEventFilter(self)
            a.removeEventFilter(self)
            self.setParent(None)

gives:

    repro.py:5: error: Missing named argument "arguments" for
"pyqtSignal"  [call-arg]
    repro.py:10: error: Argument 1 to "installEventFilter" of
"QObject" has incompatible type "B"; expected "A"  [arg-type]
    repro.py:11: error: Argument 1 to "removeEventFilter" of "QObject"
has incompatible type "B"; expected "A"  [arg-type]
    repro.py:12: error: Argument 1 to "setParent" of "QObject" has
incompatible type "None"; expected "B"  [arg-type]

With PyQt6 6.11.0 the same file passes.

So besides pyqtSignal's "arguments" having no default:

- QObject.installEventFilter(), removeEventFilter() and setParent() take
  typing.Self where any QObject is meant, and setParent() has also lost
  "| None".
- Static methods return typing.Self, where there's no instance for it to
  bind to: QCoreApplication.instance(), QDBusConnection.sessionBus(),
  QPixmap.fromImage() and QPixmap.fromImageReader().

The code runs fine on 6.12.1; only the stubs are affected.

Thanks,
Randy


More information about the PyQt mailing list