11import dataclasses
22from collections .abc import Hashable , Iterable
33from functools import cached_property
4- from typing import Any , Callable , Generic , Optional , Union
4+ from typing import Any , Callable , Generic , Optional , Union , cast
55
66import cfunits
77import numpy
@@ -228,8 +228,8 @@ def _set_up_axis(self, variable: xarray.DataArray) -> tuple[str, Formatter]:
228228 # Use cfunits to normalize the units to their short symbol form.
229229 # EngFormatter will write 'k{unit}', 'G{unit}', etc
230230 # so unit symbols are required.
231- units = cfunits .Units (units ).formatted ()
232- formatter = EngFormatter (unit = units )
231+ formatted_units = cfunits .Units (units ).formatted ()
232+ formatter = EngFormatter (unit = formatted_units )
233233
234234 return title , formatter
235235
@@ -746,7 +746,7 @@ def _plot_on_figure(
746746 depth_limit_shallow = up (transect_dataset ['depth_bounds' ][depth_start ])
747747 depth_limit_deep = down (transect_dataset ['depth_bounds' ][depth_stop ])
748748
749- axes = figure .subplots ()
749+ axes = cast ( Axes , figure .subplots () )
750750 x_title , x_formatter = self ._set_up_axis (distance_bounds )
751751 y_title , y_formatter = self ._set_up_axis (depth )
752752 axes .set_xlabel (x_title )
@@ -764,7 +764,8 @@ def _plot_on_figure(
764764 if title is not None :
765765 axes .set_title (title )
766766
767- cmap = colormaps [cmap ].copy ()
767+ if isinstance (cmap , str ):
768+ cmap = colormaps [cmap ].copy ()
768769 cmap .set_bad (ocean_floor_colour )
769770
770771 if data_array .size != 0 :
0 commit comments