Skip to content

Commit 52bb0a9

Browse files
committed
pre-commit fixes
1 parent 891f4aa commit 52bb0a9

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed

src/napari_matplotlib/base.py

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

54
import matplotlib.style as mplstyle
65
import napari
@@ -38,7 +37,7 @@ class BaseNapariMPLWidget(QWidget):
3837
def __init__(
3938
self,
4039
napari_viewer: napari.Viewer,
41-
parent: Optional[QWidget] = None,
40+
parent: QWidget | None = None,
4241
):
4342
super().__init__(parent=parent)
4443
self.viewer = napari_viewer
@@ -173,7 +172,7 @@ class NapariMPLWidget(BaseNapariMPLWidget):
173172
def __init__(
174173
self,
175174
napari_viewer: napari.viewer.Viewer,
176-
parent: Optional[QWidget] = None,
175+
parent: QWidget | None = None,
177176
):
178177
super().__init__(napari_viewer=napari_viewer, parent=parent)
179178
self._setup_callbacks()
@@ -282,7 +281,7 @@ class SingleAxesWidget(NapariMPLWidget):
282281
def __init__(
283282
self,
284283
napari_viewer: napari.viewer.Viewer,
285-
parent: Optional[QWidget] = None,
284+
parent: QWidget | None = None,
286285
):
287286
super().__init__(napari_viewer=napari_viewer, parent=parent)
288287
self.add_single_axes()

src/napari_matplotlib/histogram.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Optional, cast
1+
from typing import Any, cast
22

33
import napari
44
import numpy as np
@@ -44,7 +44,7 @@ class HistogramWidget(SingleAxesWidget):
4444
def __init__(
4545
self,
4646
napari_viewer: napari.viewer.Viewer,
47-
parent: Optional[QWidget] = None,
47+
parent: QWidget | None = None,
4848
):
4949
super().__init__(napari_viewer, parent=parent)
5050
self._update_layers(None)
@@ -121,7 +121,7 @@ class FeaturesHistogramWidget(SingleAxesWidget):
121121
def __init__(
122122
self,
123123
napari_viewer: napari.viewer.Viewer,
124-
parent: Optional[QWidget] = None,
124+
parent: QWidget | None = None,
125125
):
126126
super().__init__(napari_viewer, parent=parent)
127127

@@ -137,12 +137,12 @@ def __init__(
137137
self._update_layers(None)
138138

139139
@property
140-
def x_axis_key(self) -> Optional[str]:
140+
def x_axis_key(self) -> str | None:
141141
"""Key to access x axis data from the FeaturesTable"""
142142
return self._x_axis_key
143143

144144
@x_axis_key.setter
145-
def x_axis_key(self, key: Optional[str]) -> None:
145+
def x_axis_key(self, key: str | None) -> None:
146146
self._x_axis_key = key
147147
self._draw()
148148

@@ -166,7 +166,7 @@ def _get_valid_axis_keys(self) -> list[str]:
166166
else:
167167
return self.layers[0].features.keys()
168168

169-
def _get_data(self) -> tuple[Optional[npt.NDArray[Any]], str]:
169+
def _get_data(self) -> tuple[npt.NDArray[Any] | None, str]:
170170
"""Get the plot data.
171171
172172
Returns

src/napari_matplotlib/scatter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Optional, Union
1+
from typing import Any
22

33
import napari
44
import numpy.typing as npt
@@ -100,7 +100,7 @@ class FeaturesScatterWidget(ScatterBaseWidget):
100100
def __init__(
101101
self,
102102
napari_viewer: napari.viewer.Viewer,
103-
parent: Optional[QWidget] = None,
103+
parent: QWidget | None = None,
104104
):
105105
super().__init__(napari_viewer, parent=parent)
106106

@@ -118,7 +118,7 @@ def __init__(
118118
self._update_layers(None)
119119

120120
@property
121-
def x_axis_key(self) -> Union[str, None]:
121+
def x_axis_key(self) -> str | None:
122122
"""
123123
Key for the x-axis data.
124124
"""
@@ -133,7 +133,7 @@ def x_axis_key(self, key: str) -> None:
133133
self._draw()
134134

135135
@property
136-
def y_axis_key(self) -> Union[str, None]:
136+
def y_axis_key(self) -> str | None:
137137
"""
138138
Key for the y-axis data.
139139
"""

src/napari_matplotlib/slice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Optional
1+
from typing import Any
22

33
import matplotlib.ticker as mticker
44
import napari
@@ -30,7 +30,7 @@ class SliceWidget(SingleAxesWidget):
3030
def __init__(
3131
self,
3232
napari_viewer: napari.viewer.Viewer,
33-
parent: Optional[QWidget] = None,
33+
parent: QWidget | None = None,
3434
):
3535
# Setup figure/axes
3636
super().__init__(napari_viewer, parent=parent)

src/napari_matplotlib/util.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from typing import Optional, Union
21
from warnings import warn
32

43
import napari.qt
@@ -12,7 +11,7 @@ class Interval:
1211
An integer interval.
1312
"""
1413

15-
def __init__(self, lower_bound: Optional[int], upper_bound: Optional[int]):
14+
def __init__(self, lower_bound: int | None, upper_bound: int | None):
1615
"""
1716
Parameters
1817
----------
@@ -48,7 +47,7 @@ def __contains__(self, val: int) -> bool:
4847
return True
4948

5049
@property
51-
def _helper_text(self) -> Optional[str]:
50+
def _helper_text(self) -> str | None:
5251
"""
5352
Helper text for widgets.
5453
"""
@@ -86,9 +85,7 @@ def _has_id(nodes: list[tinycss2.ast.Node], id_name: str) -> bool:
8685
)
8786

8887

89-
def _get_dimension(
90-
nodes: list[tinycss2.ast.Node], id_name: str
91-
) -> Union[int, None]:
88+
def _get_dimension(nodes: list[tinycss2.ast.Node], id_name: str) -> int | None:
9289
"""
9390
Get the value of the DimensionToken for the IdentToken `id_name`.
9491

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy