Wrong type annotation of pyqtSlot in PyQt5

Alexander Hedges alexander.hedges at fotokite.com
Thu Sep 21 11:01:18 BST 2023


Hi,

Currently in PyQt5 (as of the latest development build) the pyqtSlot decorator
is typed as:

```python
def pyqtSlot(*args: typing.Any, name: typing.Optional[str] = ...,
result: typing.Optional[str] = ...) -> typing.Callable[...,
typing.Optional[str]]: ...
```

Which is an incorrect annotation given that this function is a decorator (it
should return a function that takes a function and returns a function).

In PyQt6 this is currently correctly annotated as returning a function that
takes a function and returns a function with the same signature:

```python
FuncT = typing.TypeVar('FuncT', bound=typing.Callable)
def pyqtSlot(*types, name: typing.Optional[str] = ..., result:
typing.Optional[str] = ...) -> typing.Callable[[FuncT], FuncT]: ...
```

It would be great if you could fix the stub file in PyQt5.

Alexander

PS: You might have already received this email, I sent it yesterday
without being subscribed
to the mailing list. I don't use mailing lists a lot and since the
message was not showing up
in the archives I decided there is a higher chance of it being
delivered if I subscribe and resend.


More information about the PyQt mailing list