Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1713

SignalInstance emit signatures incorrect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.5.0
    • 5.15.7
    • PySide
    • 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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              ctismer Christian Tismer
              talley Talley Lambert
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes