Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.15.7
-
None
-
1e47cdbd77 (pyside/pyside-setup/dev) ac8d468280 (pyside/pyside-setup/6.4) ac8d468280 (pyside/tqtc-pyside-setup/6.4) 1e47cdbd77 (pyside/tqtc-pyside-setup/dev) 1e47cdbd77 (pyside/tqtc-pyside-setup/tqtc/dev) ac8d468280 (pyside/pyside-setup/6.4.1)
Description
I would like to be able to retrieve some information about the signature of a SignalInstance (i.e. the parameters accepted by .emit) from only the SignalInstance itself (that is, without having access to the metaObject on the owner of the signal instance).
Take this example:
from PySide2.QtCore import Signal, QObject import inspect class MyObj(QObject): some_signal = Signal() obj = MyObj()
Using inspect.signature gives erroneous info:
>>> inspect.signature(obj.some_signal.emit) <Signature (*args: typing.Any) -> None> >>> obj.some_signal.emit(1) # compatible with the signature above TypeError: some_signal() only accepts 0 argument(s), 1 given!
The signature is stored in the `PySideSignalInstancePrivate` struct, and would be nice to access.
As a sidenote: PyQt adds a .signal .signatures attribute (holding the string signature) to the bound signal instance, that is sufficient for retrieving the signature. Though returning a proper `Signature` instance from `SignalInstance.__signature__` feels more correct
Attachments
Issue Links
- is required for
-
PYSIDE-1675 Improve mypy compatibility with our python stubs (pyi)
- Open
- relates to
-
PYSIDE-1603 Missing signals in stubs
- Closed
-
PYSIDE-1936 Type Hinting: Expose signals / "clicked" member variable in stub to avoid erros in static type checkers
- Closed
For Gerrit Dashboard: PYSIDE-1713 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
442485,9 | signals: Increase compatibility by providing a signatures attribute | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
443075,2 | signals: Increase compatibility by providing a signatures attribute | 6.4 | pyside/pyside-setup | Status: MERGED | +2 | 0 |