Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
6.8.1
-
None
Description
The current type hints for QmlElement, QmlUncreatable, QmlAnonymous, and QmlSingleton (and possibly others) all have an argument type of `object` and a return type of `object`. This causes problems with type checkers as these should all take some type as the argument and return that same type.
You can get seemingly correct behavior by patching `QtQml.pyi` to include, for example:
_UncreatableT = typing.TypeVar('_UncreatableT') def QmlUncreatable(reason: str | None = None) -> typing.Callable[[_UncreatableT], _UncreatableT]: ... _AnonymousT = typing.TypeVar("_AnonymousT") def QmlAnonymous(arg__1: _AnonymousT) -> _AnonymousT: ... _ElementT = typing.TypeVar("_ElementT") def QmlElement(arg__1: _ElementT) -> _ElementT: ... _SingletonT = typing.TypeVar("_SingletonT") def QmlSingleton(arg__1: _SingletonT) -> _SingletonT: ...
There may be a cleaner way to do this, but this seems to work.
Attachments
Issue Links
- duplicates
-
PYSIDE-2541 Fix type inference for QmlElement
- Reported