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

[Type Hints] Wrong type for type parameter in SignalInstance.connect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 6.5.3
    • Type hints
    • None
    • All

    Description

      SignalInstance.connect’s typing is wrong:

      def connect(self, slot: object, type: Optional[type] = ...) -> None:
       ...

      The actual typing should look like this:

      def connect(self, slot: object, type: Optional[QtCore.Qt.ConnectionType] = ...) -> None:
       ...

      Currently, mypy fails to check this code:

      button = QPushButton()
      button.clicked.connect(
       lambda: print("Button clicked"), type=Qt.ConnectionType.AutoConnection
      )

      With this error:

      error: Argument "type" to "connect" of "SignalInstance" has incompatible type "ConnectionType"; expected "type | None" [arg-type]

      Attachments

        1. pyside2533.py
          1.0 kB
          Friedemann Kleint

        Issue Links

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

          Activity

            People

              ctismer Christian Tismer
              tilmankrummeck Tilman Krummeck
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes