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

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

XMLWordPrintable

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

      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.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes