[PyQt] Type annotations for pyqtSignals

Phil Thompson phil at riverbankcomputing.com
Mon Nov 26 22:03:12 GMT 2018


On 26 Nov 2018, at 8:44 pm, Florian Bruhin <me at the-compiler.org> wrote:
> 
> Hi,
> 
> (last one... for today :D)
> 
> Where Qt has signals, PyQt's type annotations seem to say it's a normal
> function - like with QTimer.timeout:
> 
>  class QTimer(QObject):
> 
>      [...]
> 
>      def timeout(self) -> None: ...
> 
> Shouldn't signals rather be defined like "timeout: QtCore.pyqtSignal",
> which presumably also would make PyCharm suggest their
> .connect/.disconnect method properly?

Happy to change it if the behaviour is better (you tell me).

However there are cases where a a signal has the same name (but different signature obviously) as an ordinary method. Would that also work?

Phil


More information about the PyQt mailing list