PyQt6 v6.12.0 stubs - positional-only parameters missing "/"

Dragan A. forumwt at gmail.com
Mon Oct 12 21:18:00 BST 2026


Hi,

One more stub issue, this time a general one.

At runtime, PyQt methods don't accept required arguments as keywords:

    obj.eventFilter(a0=o, a1=e)  ->  TypeError: eventFilter() takes no
keyword arguments
    obj.event(a0=e)              ->  TypeError: event() takes no keyword
arguments

But the stubs declare them as normal parameters, without "/":

    def eventFilter(self, a0: 'QObject|None', a1: 'QEvent|None') -> bool:
...

Because of that, type checkers treat the names a0/a1 as part of the API, and
every override that uses meaningful names is reported as incompatible
(pyright 1.1.414):

    class Filter(QObject):
        def eventFilter(self, watched: QObject | None, event: QEvent |
None) -> bool: ...

    error: Method "eventFilter" overrides class "QObject" in an
incompatible manner
      Parameter 2 name mismatch: base parameter is named "a0", override
parameter is named "watched"

Users are forced to name their parameters a0, a1, ... or add ignore
comments.
The stubs themselves already contradict this: QObject.eventFilter uses
(a0, a1), while some QtWidgets overrides use (watched, event), (object,
event)
or (o, e).

The fix is to emit "/" after the arguments that can't be passed as keywords:

    def eventFilter(self, a0: 'QObject|None', a1: 'QEvent|None', /) ->
bool: ...
    def event(self, a0: 'QEvent|None', /) -> bool: ...

This matches the runtime behavior and lets subclasses use any parameter
names.
It applies to all generated methods, not only eventFilter.

Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20261012/30623353/attachment.htm>


More information about the PyQt mailing list