Skip to content

Commit 29c1c14

Browse files
[pre-commit.ci] pre-commit autoupdate + fix qt tests (#360)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.17.1](pre-commit/mirrors-mypy@v1.15.0...v1.17.1) - [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](pre-commit/pre-commit-hooks@v5.0.0...v6.0.0) - [github.com/astral-sh/ruff-pre-commit: v0.11.6 → v0.12.8](astral-sh/ruff-pre-commit@v0.11.6...v0.12.8) * workaround qt test (command double registration) * fix pre-commit --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Luca Marconato <[email protected]>
1 parent 0429cf1 commit 29c1c14

File tree

9 files changed

+25
-9
lines changed

9 files changed

+25
-9
lines changed

.mypy.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[mypy]
22
mypy_path = napari-spatialdata
33
python_version = 3.10
4-
plugins = numpy.typing.mypy_plugin
54

65
ignore_errors = False
76
warn_redundant_casts = True

.pre-commit-config.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default_stages:
77
minimum_pre_commit_version: 2.9.3
88
repos:
99
- repo: https://github.com/pre-commit/mirrors-mypy
10-
rev: v1.15.0
10+
rev: v1.17.1
1111
hooks:
1212
- id: mypy
1313
additional_dependencies: [numpy>=1.23]
@@ -22,16 +22,16 @@ repos:
2222
hooks:
2323
- id: prettier
2424
- repo: https://github.com/pre-commit/pre-commit-hooks
25-
rev: v5.0.0
25+
rev: v6.0.0
2626
hooks:
2727
- id: detect-private-key
2828
- id: check-merge-conflict
2929
- id: check-ast
3030
- id: check-symlinks
3131
- id: check-added-large-files
3232
- id: check-executables-have-shebangs
33-
- id: fix-encoding-pragma
34-
args: [--remove]
33+
# - id: fix-encoding-pragma
34+
# args: [--remove]
3535
- id: end-of-file-fixer
3636
- id: mixed-line-ending
3737
args: [--fix=lf]
@@ -49,7 +49,11 @@ repos:
4949
hooks:
5050
- id: blacken-docs
5151
- repo: https://github.com/astral-sh/ruff-pre-commit
52-
rev: v0.11.6
52+
rev: v0.12.8
5353
hooks:
5454
- id: ruff
5555
args: [--fix, --exit-non-zero-on-fix]
56+
- repo: https://github.com/asottile/pyupgrade
57+
rev: v3.20.0
58+
hooks:
59+
- id: pyupgrade

src/napari_spatialdata/_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def adata_layer(self) -> str | None: # noqa: D102
246246
return self._adata_layer
247247

248248
@adata_layer.setter
249-
def adata_layer(self, adata_layer: str) -> None:
249+
def adata_layer(self, adata_layer: str | None) -> None:
250250
self._adata_layer = adata_layer
251251

252252
@property

src/napari_spatialdata/_scatterwidgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def setComponent(self, text: int | str | None) -> None:
114114
elif self.getAttribute() == "obsm":
115115
if TYPE_CHECKING:
116116
assert isinstance(text, int | str)
117-
self.text = text # type: ignore[assignment]
117+
self.text = text
118118
super().setIndex(text)
119119

120120
@property

src/napari_spatialdata/utils/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def get_napari_version() -> packaging.version.Version:
487487

488488

489489
@contextmanager
490-
def block_signals(widget: QObject) -> Generator[None, None, None]:
490+
def block_signals(widget: QObject) -> Generator[None]:
491491
try:
492492
widget.blockSignals(True)
493493
yield

tests/test_cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from pathlib import Path
22

3+
import pytest
34
from click.testing import CliRunner
45
from napari.viewer import Viewer
56
from spatialdata.datasets import blobs
@@ -14,6 +15,7 @@ def test_view_exists():
1415
Viewer.close_all()
1516

1617

18+
@pytest.mark.usefixtures("mock_app_model")
1719
def test_view_path_not_exists():
1820
runner = CliRunner()
1921
with runner.isolated_filesystem():
@@ -26,6 +28,7 @@ def test_view_path_not_exists():
2628
Viewer.close_all()
2729

2830

31+
@pytest.mark.usefixtures("mock_app_model")
2932
def test_view_path_is_dir():
3033
runner = CliRunner()
3134
with runner.isolated_filesystem():

tests/test_interactive.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
)
1919

2020

21+
@pytest.mark.usefixtures("mock_app_model")
2122
class TestImages(PlotTester, metaclass=PlotTesterMeta):
2223
def test_plot_can_add_element_image(self, sdata_blobs: SpatialData):
2324
blobs_image = Image2DModel.parse(sdata_blobs["blobs_image"], c_coords=("r", "g", "b"))
@@ -51,6 +52,7 @@ def test_switch_coordinate_system(self, sdata_blobs: SpatialData):
5152
Viewer.close_all()
5253

5354

55+
@pytest.mark.usefixtures("mock_app_model")
5456
def test_plot_can_add_element_switch_cs(sdata_blobs: SpatialData):
5557
i = Interactive(sdata=sdata_blobs, headless=True)
5658
i.add_element(element="blobs_image", element_coordinate_system="global", view_element_system=True)
@@ -59,6 +61,7 @@ def test_plot_can_add_element_switch_cs(sdata_blobs: SpatialData):
5961
Viewer.close_all()
6062

6163

64+
@pytest.mark.usefixtures("mock_app_model")
6265
class TestInteractive(PlotTester, metaclass=PlotTesterMeta):
6366
def test_get_layer_existing(self, sdata_blobs: SpatialData):
6467
i = Interactive(sdata=sdata_blobs, headless=True)

tests/test_scatterwidgets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from napari_spatialdata._model import DataModel
88
from napari_spatialdata._scatterwidgets import PlotWidget
99

10+
pytestmark = pytest.mark.usefixtures("mock_app_model")
11+
12+
1013
DATA_LEN = 100
1114

1215

tests/test_widgets.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def test_layer_selection(make_napari_viewer: Any, image: ArrayLike, widget: Any,
267267
assert widget.model.adata.n_obs == 0
268268

269269

270+
@pytest.mark.usefixtures("mock_app_model")
270271
def test_export_no_rois(adata_labels):
271272
"""Test export for no rois situation."""
272273

@@ -277,6 +278,7 @@ def test_export_no_rois(adata_labels):
277278
assert scatter_widget.status_label.text() == "Status: No rois selected."
278279

279280

281+
@pytest.mark.usefixtures("mock_app_model")
280282
def test_export_no_name(adata_labels, mocker):
281283
"""Test export - no column name provided."""
282284

@@ -290,6 +292,7 @@ def test_export_no_name(adata_labels, mocker):
290292
assert scatter_widget._model.adata.obs.equals(adata_labels.obs)
291293

292294

295+
@pytest.mark.usefixtures("mock_app_model")
293296
def test_new_annotation(adata_labels, annotation_values, mocker):
294297
"""Test export - adding a new annotation."""
295298

@@ -304,6 +307,7 @@ def test_new_annotation(adata_labels, annotation_values, mocker):
304307
assert np.array_equal(scatter_widget._model.adata.obs.test, annotation_values)
305308

306309

310+
@pytest.mark.usefixtures("mock_app_model")
307311
def test_old_annotation(adata_labels, annotation_values, mocker):
308312
"""Test updating existing annotation."""
309313

0 commit comments

Comments
 (0)