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

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

      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.

        1. bug.py
          0.2 kB
          bers bers
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:

                There are no open Gerrit changes