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

QComboBox type hints differ between Windows and Linux

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • 6.8.1
    • 6.8.0
    • Type hints
    • None
    • 8a416e88c (dev), 29fb43f5b (dev), 6792f387e (6.8), c0edf645f (6.8)

    Description

      Windows:

      > more __init__.py | findstr __version__
      __version__ = "6.8.0"
      
      > more QtWidgets.pyi | findstr addItem | findstr userData
          def addItem(self, text: str, userData: typing.Any = ...) -> None: ...
          def addItem(self, icon: PySide6.QtGui.QIcon | PySide6.QtGui.QPixmap, text: str, userData: typing.Any = ...) -> None: ...
      

      Linux:

      $ grep __version__ __init__.py
      __version__ = "6.8.0"
      
      $ grep addItem QtWidgets.pyi | grepuserData
          def addItem(self, icon: PySide6.QtGui.QIcon | PySide6.QtGui.QPixmap, text: str, userData: typing.Any = ...) -> None: ...
          def addItem(self, text: str, userData: typing.Any = ...) -> None: ...
      

      Why is this a problem?

      from typing import Any, overload, override
      
      from PySide6.QtGui import QIcon, QPixmap
      from PySide6.QtWidgets import QComboBox
      
      
      class TypeChecksOnLinux(QComboBox):
          @overload
          def addItem(self, icon: QIcon | QPixmap, text: str, data: Any = ...) -> None: ...
      
          @overload
          def addItem(self, text: str, data: Any = ...) -> None: ...
      
          @override
          def addItem(self, *args: Any, **kwargs: Any) -> None: ...
      
      
      class TypeChecksWindows(QComboBox):
          @overload
          def addItem(self, text: str, data: Any = ...) -> None: ...
      
          @overload
          def addItem(self, icon: QIcon | QPixmap, text: str, data: Any = ...) -> None: ...
      
          @override
          def addItem(self, *args: Any, **kwargs: Any) -> None: ...
      

      Windows:

      > mypy bug.py
      bug.py:8: error: Signature of "addItem" incompatible with supertype "QComboBox"  [override]
      bug.py:8: note:      Superclass:
      bug.py:8: note:          @overload
      bug.py:8: note:          def addItem(self, text: str, userData: Any = ...) -> None
      bug.py:8: note:          @overload
      bug.py:8: note:          def addItem(self, icon: QIcon | QPixmap, text: str, userData: Any = ...) -> None
      bug.py:8: note:      Subclass:
      bug.py:8: note:          @overload
      bug.py:8: note:          def addItem(self, icon: QIcon | QPixmap, text: str, data: Any = ...) -> None
      bug.py:8: note:          @overload
      bug.py:8: note:          def addItem(self, text: str, data: Any = ...) -> None
      Found 1 error in 1 file (checked 1 source file)
      

      Linux:

      $ mypy bug.py
      bug.py:19: error: Signature of "addItem" incompatible with supertype "QComboBox"  [override]
      bug.py:19: note:      Superclass:
      bug.py:19: note:          @overload
      bug.py:19: note:          def addItem(self, icon: QIcon | QPixmap, text: str, userData: Any = ...) -> None
      bug.py:19: note:          @overload
      bug.py:19: note:          def addItem(self, text: str, userData: Any = ...) -> None
      bug.py:19: note:      Subclass:
      bug.py:19: note:          @overload
      bug.py:19: note:          def addItem(self, text: str, data: Any = ...) -> None
      bug.py:19: note:          @overload
      bug.py:19: note:          def addItem(self, icon: QIcon | QPixmap, text: str, data: Any = ...) -> None
      Found 1 error in 1 file (checked 1 source file)
      

      Attachments

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

        Activity

          People

            ctismer Christian Tismer
            bers bers bers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes