Skip to content

Commit

Permalink
fix: mypy matplotlib annotation fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Oct 16, 2023
1 parent c745a7d commit cd31038
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ repos:
args: ["--extend-ignore=B008,T20,I002,E402", "--fix", "--show-fixes"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.6.0
hooks:
- id: mypy
files: ^src
Expand Down
6 changes: 4 additions & 2 deletions src/hist/axis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

from typing import Any, Iterable
import typing
from collections.abc import Iterable
from typing import Any

import boost_histogram as bh
import boost_histogram.axis as bha
Expand Down Expand Up @@ -57,7 +59,7 @@ def name(self: AxisProtocol) -> str:
"""
Get the name for the Regular axis
"""
return self._ax.metadata.get("name", "")
return typing.cast(str, self._ax.metadata.get("name", ""))

@property
def label(self: AxisProtocol) -> str:
Expand Down
5 changes: 3 additions & 2 deletions src/hist/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _plot_keywords_wrapper(ax: matplotlib.axes.Axes, legend: bool | None) -> Non
# Todo: more keywords here
if legend:
if ax.get_legend_handles_labels()[0]:
legend = ax.legend()
ax.legend()
else:
raise ValueError("No labels to legend")

Expand Down Expand Up @@ -517,7 +517,8 @@ def plot_pull_array(
downRect_startpoint, patch_width, patch_height, **pp_kwargs
)
ax.add_patch(downRect)
patch_artists.append((downRect, upRect))
patch_artists.append(downRect)
patch_artists.append(upRect)

ax.set_xlim(left_edge, right_edge)

Expand Down

0 comments on commit cd31038

Please sign in to comment.