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

QMatrix element getter inconsistency

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • 6.10.0
    • PySide, Type hints
    • None
    • All

      Almost all of the QMatrix element getters are implemented with __call__ and correctly type hinted.

      QMatrix4x4 is implemented with __getitem__ and is not documented in the type hints.

      I would expect this to be consistently implemented for all QMatrix classes.

      from PySide6.QtGui import QMatrix3x3, QMatrix4x4
      
      m33 = QMatrix3x3()
      e11 = m33(0, 0)
      
      m44 = QMatrix4x4()
      e11 = m44(0, 0) # TypeError: 'PySide6.QtGui.QMatrix4x4' object is not callable
      e11 = m44[0, 0] # This is not documented in the type hints

      Either the following type hint needs to be added to QMatrix4x4 to document the real behaviour.

      def __getitem__(self, item: tuple[int, int]) -> float: ... 

      Or __call__ should be implemented on QMatrix4x4 to match the other QMatrix classes and C++.

      Personally I would prefer the latter for consistency.

      __getitem__ should be kept but undocumented for backwards compatibilty.

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

            cinucen Ece Cinucen
            gentlegiantjgc J C
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes