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

Type hints: QGuiApplication.screenAt, QGuiApplication.modalWindow (and more) should be marked optional

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • 6.10.0, 6.9.2
    • 6.9.0, 6.9.1
    • Type hints
    • None
    • da0f2625b (dev), d90b40c1b (6.9)

    Description

      In type hints, I find

          @staticmethod
          def screenAt(point: PySide6.QtCore.QPoint, /) -> PySide6.QtGui.QScreen: ...
      

      However, the C++ QGuiApplication.screenAt can return nullptr as well, and so the PySide implementation can return None: see attached code example, which outputs

      <PySide6.QtGui.QScreen(0x178779c62f0, name="\\\\.\\DISPLAY1") at 0x000001787969AC80>
      None
      

      So the type hint should be

          @staticmethod
          def screenAt(point: PySide6.QtCore.QPoint, /) -> PySide6.QtGui.QScreen | None: ...
      

      Essentially the same thing is true for QGuiApplication.modalWindow.

      Attachments

        1. bug.py
          0.2 kB
          bers bers

        Issue Links

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

          Activity

            People

              cinucen Ece Cinucen
              bers bers bers
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change