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

MyPy/PyRight error with PySide6.QtCore.Property

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.5.6, 6.7.2, 6.8.0
    • None
    • Type hints
    • None
    • c01cab8dd (dev), b00c1662d (6.7), 7b7bd14c7 (tqtc/lts-6.5)

    Description

      When using the `Property` decorator in PySide6, for example:

      @QmlElement
      class SomeObject(QObject):
          def __init__(self):
              super().__init__()
              self._name: str = "ObjectName"
      
          @Property(str)
          def name(self) -> str:
              return self._name
      

       
      Multiple type checkers fail with the error:
      error: "Property" not callable [operator]

      This seems to be caused by the Property definition in `QtCore.pyi`, though I'm struggling to see exactly why.

      QtCore.pyi: class Property(object):
      
          def __init__(self, type: type, fget: Optional[Callable] = ..., fset: Optional[Callable] = ..., freset: Optional[Callable] = ..., fdel: Optional[Callable] = ..., doc: str = ..., notify: Optional[Callable] = ..., designable: bool = ..., scriptable: bool = ..., stored: bool = ..., user: bool = ..., constant: bool = ..., final: bool = ...) -> None: ...
      
          def deleter(self, fdel: Callable) -> PySide6.QtCore.Property: ...
          def getter(self, fget: Callable) -> PySide6.QtCore.Property: ...
          def read(self, fget: Callable) -> PySide6.QtCore.Property: ...
          def setter(self, fset: Callable) -> PySide6.QtCore.Property: ...
          def write(self, fset: Callable) -> PySide6.QtCore.Property: ...
      

      Attachments

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              jtc9242 Joel Collins
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes