1
- from typing import Any , Optional , cast
1
+ from typing import Any , cast
2
2
3
3
import napari
4
4
import numpy as np
@@ -44,7 +44,7 @@ class HistogramWidget(SingleAxesWidget):
44
44
def __init__ (
45
45
self ,
46
46
napari_viewer : napari .viewer .Viewer ,
47
- parent : Optional [ QWidget ] = None ,
47
+ parent : QWidget | None = None ,
48
48
):
49
49
super ().__init__ (napari_viewer , parent = parent )
50
50
self ._update_layers (None )
@@ -121,7 +121,7 @@ class FeaturesHistogramWidget(SingleAxesWidget):
121
121
def __init__ (
122
122
self ,
123
123
napari_viewer : napari .viewer .Viewer ,
124
- parent : Optional [ QWidget ] = None ,
124
+ parent : QWidget | None = None ,
125
125
):
126
126
super ().__init__ (napari_viewer , parent = parent )
127
127
@@ -137,12 +137,12 @@ def __init__(
137
137
self ._update_layers (None )
138
138
139
139
@property
140
- def x_axis_key (self ) -> Optional [ str ] :
140
+ def x_axis_key (self ) -> str | None :
141
141
"""Key to access x axis data from the FeaturesTable"""
142
142
return self ._x_axis_key
143
143
144
144
@x_axis_key .setter
145
- def x_axis_key (self , key : Optional [ str ] ) -> None :
145
+ def x_axis_key (self , key : str | None ) -> None :
146
146
self ._x_axis_key = key
147
147
self ._draw ()
148
148
@@ -166,7 +166,7 @@ def _get_valid_axis_keys(self) -> list[str]:
166
166
else :
167
167
return self .layers [0 ].features .keys ()
168
168
169
- def _get_data (self ) -> tuple [Optional [ npt .NDArray [Any ]] , str ]:
169
+ def _get_data (self ) -> tuple [npt .NDArray [Any ] | None , str ]:
170
170
"""Get the plot data.
171
171
172
172
Returns
0 commit comments