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

Details

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

    Description

      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“

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes