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

Type hinting: Wrong Return Type for QListWidget selectedIndexes()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4: Low
    • 6.3
    • 6.2.3
    • PySide, Type hints
    • None
    • Windows

    Description

      I was using PySide6 for a project and found that the type hinting was misleading, as when I was using the function selectedIndexes() on a QListWidget, i was (theoretically in the type hints) recieving a

      List[int]

      when in fact the return type was

      List[PySide6.QtCore.QModelIndex]

      . Hopefully this information will help other people that find themselves in my position. It's nothing major as it only affects type hinting and I can override the type hints by giving the variable itself a type hint, but it would be a nice QOL change.

       

      Given that QListWidget uses QListView as a base, the change should be made there and not in QListWidget. The QtWidgets.pyi file shows that the "error" is in QListView.

      Attachments

        For Gerrit Dashboard: PYSIDE-1934
        # Subject Branch Project Status CR V

        Activity

          People

            shpremna Shyamnath Premnadh
            nil6nil6 Nil Vilas Basil
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes