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

Property decorator type annotations are lacking

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • 6.9.3
    • Type hints
    • None

      Hi, I hit a pretty big problem that seems easily fixable - the Property object/decorator should have templated hinting where getter/setter annotations actually reflect the property type. Currently what I see in the header is:

      class Property:
      
          def __init__(self, type: type, /, fget: collections.abc.Callable[[typing.Any], typing.Any] | None = ..., fset: collections.abc.Callable[[typing.Any, typing.Any], None] | None = ..., freset: collections.abc.Callable[[typing.Any, typing.Any], None] | None = ..., doc: str | None = ..., notify: PySide6.QtCore.Signal | None = ..., designable: bool = ..., scriptable: bool = ..., stored: bool = ..., user: bool = ..., constant: bool = ..., final: bool = ...) -> None: ...
      
          def __call__(self, func: collections.abc.Callable[..., typing.Any], /) -> PySide6.QtCore.Property: ...
          def deleter(self, fdel: collections.abc.Callable[[typing.Any], None], /) -> PySide6.QtCore.Property: ...
          def getter(self, fget: collections.abc.Callable[[typing.Any], typing.Any], /) -> PySide6.QtCore.Property: ...
          def read(self, fget: collections.abc.Callable[[typing.Any], typing.Any], /) -> PySide6.QtCore.Property: ...
          def setter(self, fset: collections.abc.Callable[[typing.Any, typing.Any], None], /) -> PySide6.QtCore.Property: ...
          def write(self, fset: collections.abc.Callable[[typing.Any, typing.Any], None], /) -> PySide6.QtCore.Property: ...
      

      And I this error when trying to assign a value (42) to a property
      Cannot assign to attribute "foo" for class "MyObject"
      "Literal[42]" is not assignable to "Property"

      and when using Property as a decorator i get redeclaration errors:
      Method declaration "foo" is obscured by a declaration of the same namePylancereportRedeclaration

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

            cinucen Ece Cinucen
            petko10 Petko Ditchev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes