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

qt.pyside.libpyside.warning does not warn about an unannotated slot when it is nested inside a class method

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 6.7.2
    • PySide
    • None

    Description

      When running an application with the following code and the environment variable QT_LOGGING_RULES set to "qt.pyside.libpyside.warning=true":

      from PySide6.QtWidgets import QApplication, QWidget, QPushButton
      from PySide6.QtCore import Slot
      
      class Window(QWidget):
          def __init__(self):
              super().__init__()
              self.button = QPushButton()
              self.button.clicked.connect(self.click_func)
      
          def click_func(self):
              pass
      
      app = QApplication()
      window = Window()
      window.show()
      app.exec()
      

      The console correctly outputs the following message:

      qt.pyside.libpyside: Warning: Registering dynamic slot "click_func()" on "Window". Consider annotating with @Slot()

      However, when you nest the click_func() function into another function, like the following code, it does not print any such message:

      from PySide6.QtWidgets import QApplication, QWidget, QPushButton
      from PySide6.QtCore import Slot
      
      class Window(QWidget):
          def __init__(self):
              def click_func():
                  pass
              super().__init__()
              self.button = QPushButton()
              self.button.clicked.connect(click_func)
      
      app = QApplication()
      window = Window()
      window.show()
      app.exec()
      

       

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            sammycyber Sammy Cyber
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes