Skip to content

Commit

Permalink
style: add some grep checks
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii authored and andrzejnovak committed Jan 12, 2022
1 parent ecf61eb commit f330654
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,15 @@ repos:
- id: codespell
args: ["-L", "hist,heros"]
exclude: "^examples/Examples.ipynb$"

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.9.0"
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-log-warn
- id: python-no-eval
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. mplhep documentation master file, created by
sphinx-quickstart on Sun Apr 12 14:08:38 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
contain the root ``toctree`` directive.
======
Expand Down
10 changes: 6 additions & 4 deletions src/mplhep/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_plottable_protocol_bins(
out = np.arange(len(axis) + 1).astype(float)
if isinstance(axis[0], tuple): # Regular axis
out[0] = axis[0][0]
out[1:] = [axis[i][1] for i in range(len(axis))] # type: ignore
out[1:] = [axis[i][1] for i in range(len(axis))] # type: ignore[index]
labels = None
else: # Categorical axis
labels = np.array([axis[i] for i in range(len(axis))])
Expand Down Expand Up @@ -95,18 +95,20 @@ def process_histogram_parts(
):
return _process_histogram_parts_iter(H, *bins)
else:
return _process_histogram_parts_iter((H,), *bins) # type: ignore
return _process_histogram_parts_iter((H,), *bins) # type: ignore[arg-type]


def _process_histogram_parts_iter(
hists: Iterable[ArrayLike] | Iterable[PlottableHistogram],
*bins: Sequence[float | None],
) -> Iterable[PlottableHistogram]:
original_bins: tuple[Sequence[float], ...] = bins # type: ignore
original_bins: tuple[Sequence[float], ...] = bins # type: ignore[assignment]

for hist in hists:
h = hist_object_handler(hist, *bins)
current_bins: tuple[Sequence[float], ...] = tuple(get_plottable_protocol_bins(a)[0] for a in h.axes) # type: ignore
current_bins: tuple[Sequence[float], ...] = tuple(
get_plottable_protocol_bins(a)[0] for a in h.axes # type: ignore[misc]
)
if any(b is None for b in original_bins):
original_bins = current_bins
if len(current_bins) != len(original_bins):
Expand Down

0 comments on commit f330654

Please sign in to comment.