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

Slot() decorator breaks type checking support

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P4: Low
    • None
    • 6.5.0
    • PySide, Type hints
    • None
    • Windows

    Description

      Using the Slot() decorator on a method with type hints breaks type checking support.

      Minimal example:

      from PySide6.QtCore import QObject, Slot
      
      class A(QObject):
          # @Slot(str)
          def foo(self, text: str) -> None:
              print(text.lower())
      
      a = A()
      a.foo(123)
      

      Without Slot decorator, type mismatches are correctly reported:

      With Slot decorator, no type mismatches can be found:


      For the minimal example it works if I just annotate the Slot class like this:

      Of course, that just passes along the signature of the decorated method.

      It will not check if the type of the slot also matches. That might not be possible without a custom plugin. But i guess it's better to report some errors than nothing at all.

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            maxxpower Markus Fleischhacker
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes