From f3306544614bfcd1b8a4c03e08488440b000b75e Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 12 Jan 2022 11:20:32 -0500 Subject: [PATCH] style: add some grep checks --- .pre-commit-config.yaml | 12 ++++++++++++ docs/source/index.rst | 2 +- src/mplhep/utils.py | 10 ++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a404cd3a..22a95753 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/docs/source/index.rst b/docs/source/index.rst index c8a36155..4b411001 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -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. ====== diff --git a/src/mplhep/utils.py b/src/mplhep/utils.py index ac6c689b..3eecea00 100644 --- a/src/mplhep/utils.py +++ b/src/mplhep/utils.py @@ -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))]) @@ -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):