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

Type-stubs rely on deprecated bytes type promotion

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • 6.5.4, 6.6.2
    • 6.6.0, 6.5.3
    • PySide, Type hints
    • None
    • eeda9bf85 (dev), 238a979f9 (6.6), 7390c652a (tqtc/lts-6.5)

    Description

      The current type stubs seem to rely on an old poorly documented (and now deprecated) behaviour where type checkers would treat `bytes` as the union `bytes | bytearray | memoryview` in annotations.

      The union should now be explicit, or even better (especially for c-bindings, like PySide) use the new Buffer Protocol. See https://peps.python.org/pep-0688/

      pyright 1.1.329 now stops implying `bytes` as `bytes | bytearray | memoryview` union by default in strict mode ( https://github.com/microsoft/pyright/releases/tag/1.1.329 )

      mypy has two hidden flags (--disable-bytearray-promotionĀ andĀ --disable-memoryview-promotion) which will be default in the next major version (see https://github.com/python/mypy/issues/15313 )

      For instance, passing a `memoryview` to `QImage` will now result in an error in strict mode

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            avasam Samuel Therrien
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes