Skip to content

Commit

Permalink
replace type: ignore[attr-defined] with assert hasattr
Browse files Browse the repository at this point in the history
  • Loading branch information
headtr1ck committed Sep 12, 2023
1 parent f7246fe commit 33c6f20
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions xarray/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,8 @@ def test_colors_np_levels(self) -> None:
assert self._color_as_tuple(colors[1]) == (1.0, 0.0, 0.0)
assert self._color_as_tuple(colors[2]) == (1.0, 1.0, 1.0)
# the last color is now under "over"
assert self._color_as_tuple(cmap._rgba_over) == (0.0, 0.0, 1.0) # type: ignore[attr-defined]
assert hasattr(cmap, "_rgba_over")
assert self._color_as_tuple(cmap._rgba_over) == (0.0, 0.0, 1.0)

def test_cmap_and_color_both(self) -> None:
with pytest.raises(ValueError):
Expand Down Expand Up @@ -2160,8 +2161,10 @@ def test_colorbar_scatter(self) -> None:
fg: xplt.FacetGrid = ds.plot.scatter(x="a", y="a", row="x", hue="a")
cbar = fg.cbar
assert cbar is not None
assert cbar.vmin == 0 # type: ignore[attr-defined]
assert cbar.vmax == 3 # type: ignore[attr-defined]
assert hasattr(cbar, "vmin")
assert cbar.vmin == 0
assert hasattr(cbar, "vmax")
assert cbar.vmax == 3

@pytest.mark.slow
def test_empty_cell(self) -> None:
Expand Down Expand Up @@ -2785,7 +2788,8 @@ def test_non_numeric_legend(self) -> None:
axes = pc.axes
assert axes is not None
# should make a discrete legend
assert axes.legend_ is not None # type:ignore[attr-defined]
assert hasattr(axes, "legend_")
assert axes.legend_ is not None

def test_legend_labels(self) -> None:
# regression test for #4126: incorrect legend labels
Expand Down

0 comments on commit 33c6f20

Please sign in to comment.