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

PySide6: QCoreApplication.translate() expects bytes according to type stubs

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4: Low
    • 6.5.2, 6.6.0
    • 6.5.0
    • Type hints
    • None
    • Python 3.11
    • Linux/X11
    • 551e6d68e (dev), a31777a69 (6.5)

    Description

      QtCore.pyi has this type stub for QCoreApplication:

      class QCoreApplication(PySide6.QtCore.QObject):
          }}{{# ...
          @staticmethod
          def translate(context: bytes, key: bytes, disambiguation: Optional[bytes] = ..., n: int = ...) -> str: ...

      Actually passing a bytes argument causes a runtime error, while passing in a str is rejected by the type checker, but works fine at runtime.

      The same issue apparently already existed for QObject: https://bugreports.qt.io/browse/PYSIDE-1329

      Expected is to have the arguments properly declared as str in the type stubs.

      Attachments

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              phip Philipp Burch
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes