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

QCoreApplication.instance() should hint return as optional

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 6.1
    • 5.15.2
    • PySide
    • None
    • 890256cc048452e4632eacc6e8882bd5821f07f3 (pyside/pyside-setup/dev) cbcb9ccd3a89be02ce0ee770f866d78177f56bf2 (pyside/pyside-setup/dev) fb60f6a15e6c94a9c8b8ec2275239df6a01d850f (pyside/pyside-setup/6.1)

    Description

      QtCore.QCoreApplication.instance() can return None per https://doc.qt.io/qt-5/qcoreapplication.html#instance. It ought to be hinted as follows.

      class QCoreApplication(PySide2.QtCore.QObject):
          @staticmethod
          def instance() -> typing.Optional["QCoreApplication"]: ...
      

      Just because, here's the PyQt5-stubs code (just fixed today...).

      https://github.com/stlehmann/PyQt5-stubs/blob/a3b2eeba10cbd9db4a2840a3b2a53c15d31039c2/PyQt5-stubs/QtCore.pyi#L3022-L3023

          @staticmethod
          def instance() -> typing.Optional['QCoreApplication']: ...
      

      As always, thanks for the work on cleaning this stuff up.

      Attachments

        Issue Links

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

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              altendky Kyle Altendorf
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes