Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
- run: uv run pyright
- run: uv run --with pyqt6 pyright

test:
name: ${{ matrix.platform }} py${{ matrix.python-version }}
Expand Down Expand Up @@ -152,11 +152,11 @@ jobs:
dependency-extras: "testing"
qt: ${{ matrix.qt }}
pytest-args: 'src/napari/_qt/_qapp_model src/napari/_app_model src/napari/utils/_tests/test_key_bindings.py --import-mode=importlib -k "not async and not qt_dims_2"'
python-version: "3.10"
python-version: "3.11"
strategy:
fail-fast: false
matrix:
qt: ["pyqt5", "pyside2"]
qt: ["pyqt5", "pyside6"]

build-and-inspect-package:
name: Build & inspect package.
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pyqt5 = [
"pyqt5-qt5==5.15.2; sys_platform == 'win32'",
"pyqt5-qt5>=5.15.4; sys_platform != 'win32'",
]
pyqt6 = ["app-model[qt]", "PyQt6>=6.4.0"]
pyqt6 = ["app-model[qt]", "PyQt6>=6.4.0", "pyqt6-qt6>=6.4.0"]
pyside2 = ["app-model[qt]", "PySide2>=5.15.2.1"]
pyside6 = ["app-model[qt]", "PySide6>=6.6.0"]

Expand All @@ -77,7 +77,7 @@ dev = [
"mypy>=1.13.0",
"pdbpp>=0.11.6; sys_platform != 'win32'",
"pre-commit-uv>=4",
"pyqt6>=6.8.0",
# "pyqt6>=6.8.0",
"rich>=13.9.4",
"pyright>=1.1.402",
]
Expand Down
6 changes: 3 additions & 3 deletions src/app_model/backends/qt/_qkeymap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from functools import reduce
from typing import TYPE_CHECKING

from qtpy import API, QT_VERSION # pyright: ignore[reportAttributeAccessIssue]
from qtpy.QtCore import QCoreApplication, Qt
from qtpy.QtGui import QKeySequence

Expand Down Expand Up @@ -86,8 +85,9 @@ def simple_keybinding_to_qint(skb: SimpleKeyBinding) -> int:
return int(out)


if QT6 and not (API == "pyside6" and int(QT_VERSION[2]) < 4):

if QT6:
# note: this doesn't work on pyside6 < 6.5 ...
# but we don't support that anymore
def _get_qmods(key: QKeyCombination) -> Qt.KeyboardModifier:
return key.keyboardModifiers()

Expand Down
8 changes: 5 additions & 3 deletions src/app_model/types/_keys/_keybindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ def _parse_input(cls, v: Any) -> "SimpleKeyBinding":
return cls.from_int(v)
raise TypeError(f"invalid type: {type(v)}")

@model_validator(mode="after") # type: ignore
@model_validator(mode="before")
@classmethod
def _model_val(cls, instance: "SimpleKeyBinding") -> "SimpleKeyBinding":
return cls._parse_input(instance)
def _model_val(cls, val: "SimpleKeyBinding") -> "SimpleKeyBinding":
if not isinstance(val, (SimpleKeyBinding, dict)):
return cls._parse_input(val)
return val


MIN1 = {"min_length": 1}
Expand Down