Skip to content

Commit ec8e43d

Browse files
authored
fix: fix pydantic deprecation warning (#269)
* fix: fix pydantic warning * fix pyside parsing * fix check * add back dev pyqt6 * no no... that was a good change * pin both lower * bump napari version * try pyside6
1 parent 6a228ea commit ec8e43d

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
steps:
2727
- uses: actions/checkout@v5
2828
- uses: astral-sh/setup-uv@v7
29-
- run: uv run pyright
29+
- run: uv run --with pyqt6 pyright
3030

3131
test:
3232
name: ${{ matrix.platform }} py${{ matrix.python-version }}
@@ -152,11 +152,11 @@ jobs:
152152
dependency-extras: "testing"
153153
qt: ${{ matrix.qt }}
154154
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"'
155-
python-version: "3.10"
155+
python-version: "3.11"
156156
strategy:
157157
fail-fast: false
158158
matrix:
159-
qt: ["pyqt5", "pyside2"]
159+
qt: ["pyqt5", "pyside6"]
160160

161161
build-and-inspect-package:
162162
name: Build & inspect package.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pyqt5 = [
5555
"pyqt5-qt5==5.15.2; sys_platform == 'win32'",
5656
"pyqt5-qt5>=5.15.4; sys_platform != 'win32'",
5757
]
58-
pyqt6 = ["app-model[qt]", "PyQt6>=6.4.0"]
58+
pyqt6 = ["app-model[qt]", "PyQt6>=6.4.0", "pyqt6-qt6>=6.4.0"]
5959
pyside2 = ["app-model[qt]", "PySide2>=5.15.2.1"]
6060
pyside6 = ["app-model[qt]", "PySide6>=6.6.0"]
6161

@@ -77,7 +77,7 @@ dev = [
7777
"mypy>=1.13.0",
7878
"pdbpp>=0.11.6; sys_platform != 'win32'",
7979
"pre-commit-uv>=4",
80-
"pyqt6>=6.8.0",
80+
# "pyqt6>=6.8.0",
8181
"rich>=13.9.4",
8282
"pyright>=1.1.402",
8383
]

src/app_model/backends/qt/_qkeymap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from functools import reduce
88
from typing import TYPE_CHECKING
99

10-
from qtpy import API, QT_VERSION # pyright: ignore[reportAttributeAccessIssue]
1110
from qtpy.QtCore import QCoreApplication, Qt
1211
from qtpy.QtGui import QKeySequence
1312

@@ -86,8 +85,9 @@ def simple_keybinding_to_qint(skb: SimpleKeyBinding) -> int:
8685
return int(out)
8786

8887

89-
if QT6 and not (API == "pyside6" and int(QT_VERSION[2]) < 4):
90-
88+
if QT6:
89+
# note: this doesn't work on pyside6 < 6.5 ...
90+
# but we don't support that anymore
9191
def _get_qmods(key: QKeyCombination) -> Qt.KeyboardModifier:
9292
return key.keyboardModifiers()
9393

src/app_model/types/_keys/_keybindings.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,12 @@ def _parse_input(cls, v: Any) -> "SimpleKeyBinding":
159159
return cls.from_int(v)
160160
raise TypeError(f"invalid type: {type(v)}")
161161

162-
@model_validator(mode="after") # type: ignore
162+
@model_validator(mode="before")
163163
@classmethod
164-
def _model_val(cls, instance: "SimpleKeyBinding") -> "SimpleKeyBinding":
165-
return cls._parse_input(instance)
164+
def _model_val(cls, val: "SimpleKeyBinding") -> "SimpleKeyBinding":
165+
if not isinstance(val, (SimpleKeyBinding, dict)):
166+
return cls._parse_input(val)
167+
return val
166168

167169

168170
MIN1 = {"min_length": 1}

0 commit comments

Comments
 (0)