Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
6.8.2
-
None
Description
in the current packaged version of PySide6 you can find, in .venv/lib/python3.13/site-packages/PySide6/QtCore.pyi the following definition for Slot :
class Slot(object):
def __init__(self, /, *types: type, name: str | None= ..., result: type | None= ...) -> None: ...
def __call__(self, function: typing.Callable[[typing.Any], typing.Any], /) -> typing.Any: ...
this definition, however, makes mypy raise errors if Slot annotates a method. For example, see on mypy play - also here:
import typing class Slot(object): def __init__(self, /, *types: type, name: str | None= ..., result: type | None= ...) -> None: ... def __call__(self, function: typing.Callable[[typing.Any], typing.Any], /) -> typing.Any: ... class Foo: @Slot(str) def bar(self, mystr: str) -> None: pass
you will get the error:
main.py:10: error: Argument 1 to "_call_" of "Slot" has incompatible type "Callable[[Foo, str], None]"; expected "Callable[[Any], Any]" [arg-type]
Attachments
Issue Links
- duplicates
-
PYSIDE-2942 Type hints: Slot() annotations fails in different cases
-
- Reported
-