Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.8.2
-
None
Description
The following two code examples run fine yet are pointed out as errors by mypy 1.14.1:
Example 1: hit x to close app
from PySide6.QtGui import QShortcut from PySide6.QtWidgets import QApplication, QLabel app = QApplication() label = QLabel("Hello World!") label.show() QShortcut("x", label).activated.connect(app.closeAllWindows) app.exec()
Example 2: hit ctrl-x to close app
from PySide6.QtCore import QKeyCombination, Qt from PySide6.QtGui import QShortcut from PySide6.QtWidgets import QApplication, QLabel app = QApplication() label = QLabel("Hello World!") label.show() QShortcut( QKeyCombination(Qt.KeyboardModifier.ControlModifier, Qt.Key.Key_X), label ).activated.connect(app.closeAllWindows) app.exec()
Errors are
bug1.py:7: error: No overload variant of "QShortcut" matches argument types "str", "QLabel" [call-overload] bug1.py:7: note: Possible overload variants: bug1.py:7: note: def QShortcut(self, QKeySequence, QObject, Callable[..., Any], /, context: ShortcutContext = ..., *, enabled: bool | None = ..., autoRepeat: bool | None = ...) -> QShortcut bug1.py:7: note: def QShortcut(self, QKeySequence, QObject, /, member: bytes | bytearray | memoryview[int] | None = ..., ambiguousMember: bytes | bytearray | memoryview[int] | None = ..., context: ShortcutContext = ..., *, enabled: bool | None = ..., autoRepeat: bool | None = ...) -> QShortcut bug1.py:7: note: def QShortcut(self, QObject, /, *, key: QKeySequence | None = ..., enabled: bool | None = ..., autoRepeat: bool | None = ..., context: ShortcutContext | None = ...) -> QShortcut bug1.py:7: note: def QShortcut(self, StandardKey, QObject, Callable[..., Any], /, context: ShortcutContext = ..., *, key: QKeySequence | None = ..., enabled: bool | None = ..., autoRepeat: bool | None = ...) -> QShortcut bug1.py:7: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-call-overload for more info Found 1 error in 1 file (checked 1 source file)
and
bug2.py:8: error: No overload variant of "QShortcut" matches argument types "QKeyCombination", "QLabel" [call-overload] bug2.py:8: note: Possible overload variants: bug2.py:8: note: def QShortcut(self, QKeySequence, QObject, Callable[..., Any], /, context: ShortcutContext = ..., *, enabled: bool | None = ..., autoRepeat: bool | None = ...) -> QShortcut bug2.py:8: note: def QShortcut(self, QKeySequence, QObject, /, member: bytes | bytearray | memoryview[int] | None = ..., ambiguousMember: bytes | bytearray | memoryview[int] | None = ..., context: ShortcutContext = ..., *, enabled: bool | None = ..., autoRepeat: bool | None = ...) -> QShortcut bug2.py:8: note: def QShortcut(self, QObject, /, *, key: QKeySequence | None = ..., enabled: bool | None = ..., autoRepeat: bool | None = ..., context: ShortcutContext | None = ...) -> QShortcut bug2.py:8: note: def QShortcut(self, StandardKey, QObject, Callable[..., Any], /, context: ShortcutContext = ..., *, key: QKeySequence | None = ..., enabled: bool | None = ..., autoRepeat: bool | None = ...) -> QShortcut bug2.py:8: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-call-overload for more info Found 1 error in 1 file (checked 1 source file)
from
@typing.overload def __init__(self, key: PySide6.QtGui.QKeySequence, parent: PySide6.QtCore.QObject, callable: typing.Callable[..., typing.Any], /, context: PySide6.QtCore.Qt.ShortcutContext = ..., *, enabled: bool | None= ..., autoRepeat: bool | None= ...) -> None: ... @typing.overload def __init__(self, key: PySide6.QtGui.QKeySequence, parent: PySide6.QtCore.QObject, /, member: bytes | bytearray | memoryview | None= ..., ambiguousMember: bytes | bytearray | memoryview | None= ..., context: PySide6.QtCore.Qt.ShortcutContext = ..., *, enabled: bool | None= ..., autoRepeat: bool | None= ...) -> None: ... @typing.overload def __init__(self, parent: PySide6.QtCore.QObject, /, *, key: PySide6.QtGui.QKeySequence | None= ..., enabled: bool | None= ..., autoRepeat: bool | None= ..., context: PySide6.QtCore.Qt.ShortcutContext | None= ...) -> None: ... @typing.overload def __init__(self, standard_key: PySide6.QtGui.QKeySequence.StandardKey, parent: PySide6.QtCore.QObject, callable: typing.Callable[..., typing.Any], /, context: PySide6.QtCore.Qt.ShortcutContext = ..., *, key: PySide6.QtGui.QKeySequence | None= ..., enabled: bool | None= ..., autoRepeat: bool | None= ...) -> None: ...
from
explicit QShortcut(QObject *parent); explicit QShortcut(const QKeySequence& key, QObject *parent, const char *member = nullptr, const char *ambiguousMember = nullptr, Qt::ShortcutContext context = Qt::WindowShortcut); explicit QShortcut(QKeySequence::StandardKey key, QObject *parent, const char *member = nullptr, const char *ambiguousMember = nullptr, Qt::ShortcutContext context = Qt::WindowShortcut);