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

[Type Hints] Return type for QLayout.itemAtPosition must be optional

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4: Low P4: Low
    • None
    • 6.5.3
    • Type hints
    • None
    • All

      The following code example shows that the return type of QLayout.itemAtPostion must be `QLayoutItem | None`:

       

      from typing import TYPE_CHECKING
      from PySide6.QtWidgets import QGridLayout
      layout = QGridLayout()
      item = layout.itemAtPosition(0, 0)
      print(f"Got {item}")
      if TYPE_CHECKING:
          reveal_type(item)
       
      

      When I run the code:

      Got None

      When I run mypy:

      note: Revealed type is "PySide6.QtWidgets.QLayoutItem“

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

            ctismer Christian Tismer
            tilmankrummeck Tilman Krummeck
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes