diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 574deeb4..b34a573a 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -40,9 +40,22 @@ class pyqtBoundSignal: @typing.overload def disconnect(self, slot: typing.Union["PYQT_SLOT", "QMetaObject.Connection"]) -> None: ... - +_SignalTypesT = typing.TypeVar("_SignalTypesT", type, typing.List[type]) class pyqtSignal: - def __init__(self, *types: typing.Any, name: str = ...) -> None: ... + @typing.overload + def __init__(self, *types: _SignalTypesT) -> None: ... + @typing.overload + def __init__(self, *types: _SignalTypesT, name: str) -> None: ... + @typing.overload + def __init__(self, *types: _SignalTypesT, name: str, revision: int) -> None: ... + @typing.overload + def __init__(self, *types: _SignalTypesT, name: str, revision: int, arguments: typing.List[str]) -> None: ... + @typing.overload + def __init__(self, *types: _SignalTypesT, revision: int) -> None: ... + @typing.overload + def __init__(self, *types: _SignalTypesT, revision: int, arguments: typing.List[str]) -> None: ... + @typing.overload + def __init__(self, *types: _SignalTypesT, arguments: typing.List[str]) -> None: ... @typing.overload def __get__(self, instance: None, owner: typing.Type["QObject"]) -> "pyqtSignal": ... diff --git a/tests/pyqtsignal.py b/tests/pyqtsignal.py index 139b9de9..166edc90 100644 --- a/tests/pyqtsignal.py +++ b/tests/pyqtsignal.py @@ -3,13 +3,18 @@ class Class(QtCore.QObject): - signal = QtCore.pyqtSignal([str]) # type: typing.ClassVar[QtCore.pyqtSignal] + signal1 = QtCore.pyqtSignal([str]) # type: typing.ClassVar[QtCore.pyqtSignal] + signal2 = QtCore.pyqtSignal(int) + signal3 = QtCore.pyqtSignal([str, bool], [float]) + signal4 = QtCore.pyqtSignal(int, name="cool_signal") + signal5 = QtCore.pyqtSignal(type, revision=2) + signal6 = QtCore.pyqtSignal(bool, arguments=["bool_arg"]) -Class.signal.__get__ +Class.signal1.__get__ instance = Class() -instance.signal.emit -instance.signal.connect -instance.signal.disconnect -instance.signal[str].emit +instance.signal1.emit +instance.signal1.connect +instance.signal1.disconnect +instance.signal1[str].emit