Skip to content

Commit 1b61882

Browse files
chore(backport): Update pre-commit hooks (#2492)
* Backport: - PR #2442 - PR #2464 - PR #2474 - PR #2480
1 parent 0b5b9e5 commit 1b61882

39 files changed

+92
-56
lines changed

.github/workflows/bump-version.yml

+9-15
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ on:
1212
- minor
1313
- major
1414
release_candidate:
15-
type: choice
16-
description: 'Release candidate?'
17-
options:
18-
- false
19-
- true
15+
type: boolean
16+
description: 'Release candidate'
17+
default: false
2018
new_version:
2119
description: 'New version to bump to'
2220
required: true
@@ -27,17 +25,13 @@ on:
2725
required: true
2826
type: string
2927
force:
30-
type: choice
31-
description: 'Force override check?'
32-
options:
33-
- false
34-
- true
28+
type: boolean
29+
description: 'Force override check'
30+
default: false
3531
dry_run:
36-
type: choice
37-
description: 'Perform a dry run to check?'
38-
options:
39-
- true
40-
- false
32+
type: boolean
33+
description: 'Perform a dry run to check'
34+
default: true
4135

4236
jobs:
4337
bump-version:

.github/workflows/publish-package.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ on:
1717
workflow_dispatch:
1818
inputs:
1919
publish:
20-
type: choice
21-
description: 'Publish to TestPyPI?'
22-
options:
23-
- false
24-
- true
20+
type: boolean
21+
description: 'Publish to TestPyPI'
22+
default: false
2523

2624
concurrency:
2725
group: ${{ github.workflow }}-${{ github.ref }}

.pre-commit-config.yaml

+15-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.5.0
7+
rev: v4.6.0
88
hooks:
99
- id: check-added-large-files
1010
- id: check-case-conflict
@@ -35,13 +35,13 @@ repos:
3535
- id: rst-inline-touching-normal
3636

3737
- repo: https://github.com/astral-sh/ruff-pre-commit
38-
rev: "v0.1.9"
38+
rev: "v0.4.3"
3939
hooks:
4040
- id: ruff
4141
args: ["--fix", "--show-fixes"]
4242

4343
- repo: https://github.com/psf/black-pre-commit-mirror
44-
rev: 23.12.1
44+
rev: 24.4.2
4545
hooks:
4646
- id: black-jupyter
4747
types_or: [python, pyi, jupyter]
@@ -50,10 +50,10 @@ repos:
5050
rev: 1.16.0
5151
hooks:
5252
- id: blacken-docs
53-
additional_dependencies: [black==23.12.1]
53+
additional_dependencies: [black==24.4.2]
5454

5555
- repo: https://github.com/pre-commit/mirrors-mypy
56-
rev: v1.8.0
56+
rev: v1.10.0
5757
# check the oldest and newest supported Pythons
5858
hooks:
5959
- &mypy
@@ -64,12 +64,20 @@ repos:
6464
['numpy', 'types-tqdm', 'click', 'types-jsonpatch', 'types-pyyaml', 'types-jsonschema', 'importlib_metadata', 'packaging']
6565
args: ["--python-version=3.8"]
6666
- <<: *mypy
67-
name: mypy with Python 3.11
68-
args: ["--python-version=3.11"]
67+
name: mypy with Python 3.12
68+
args: ["--python-version=3.12"]
6969

7070
- repo: https://github.com/codespell-project/codespell
7171
rev: v2.2.6
7272
hooks:
7373
- id: codespell
7474
files: ^.*\.(py|md|rst)$
7575
args: ["-w", "-L", "hist,gaus"]
76+
77+
- repo: https://github.com/python-jsonschema/check-jsonschema
78+
rev: 0.28.4
79+
hooks:
80+
- id: check-readthedocs
81+
args: ["--verbose"]
82+
- id: check-github-workflows
83+
args: ["--verbose"]

docs/examples/notebooks/ImpactPlot.ipynb

+5-3
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,11 @@
172172
" model, _, b, e = fitresults()\n",
173173
" widths = pyhf.tensorlib.concatenate(\n",
174174
" [\n",
175-
" model.config.param_set(k).width()\n",
176-
" if model.config.param_set(k).constrained\n",
177-
" else [None] * model.config.param_set(k).n_parameters\n",
175+
" (\n",
176+
" model.config.param_set(k).width()\n",
177+
" if model.config.param_set(k).constrained\n",
178+
" else [None] * model.config.param_set(k).n_parameters\n",
179+
" )\n",
178180
" for k, v in model.config.par_map.items()\n",
179181
" ]\n",
180182
" )\n",

src/pyhf/cli/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The pyhf command line interface."""
2+
23
from pyhf.cli.cli import pyhf as cli
34
from pyhf.cli.rootio import cli as rootio
45
from pyhf.cli.spec import cli as spec

src/pyhf/cli/cli.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The pyhf Command Line Interface."""
2+
23
import logging
34

45
import click

src/pyhf/cli/complete.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'''Shell completions for pyhf.'''
2+
23
import click
34

45
try:

src/pyhf/cli/infer.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The inference CLI group."""
2+
23
import logging
34

45
import click

src/pyhf/cli/patchset.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The pyhf spec CLI subcommand."""
2+
23
import logging
34

45
import click

src/pyhf/cli/rootio.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""CLI subapps to handle conversion from ROOT."""
2+
23
import logging
34

45
import click

src/pyhf/cli/spec.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The pyhf spec CLI subcommand."""
2+
23
import logging
34

45
import click
@@ -149,9 +150,11 @@ def inspect(workspace, output_file, measurement):
149150
('(*) ' if measurement_name == default_measurement['name'] else '')
150151
+ measurement_name,
151152
measurement_poi,
152-
','.join(measurement_parameters)
153-
if measurement_parameters
154-
else '(none)',
153+
(
154+
','.join(measurement_parameters)
155+
if measurement_parameters
156+
else '(none)'
157+
),
155158
)
156159
)
157160

src/pyhf/contrib/cli.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""CLI for functionality that will get migrated out eventually."""
2+
23
import logging
34
import click
45
from pathlib import Path

src/pyhf/contrib/viz/brazil.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Brazil Band Plots."""
2+
23
from collections import namedtuple
34

45
import matplotlib.pyplot as plt

src/pyhf/infer/calculators.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
Using the calculators hypothesis tests can then be performed.
99
"""
10+
1011
from pyhf.infer.mle import fixed_poi_fit
1112
from pyhf import get_backend
1213
from pyhf.infer import utils

src/pyhf/infer/intervals/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Interval estimation"""
2+
23
import pyhf.infer.intervals.upper_limits
34

45
__all__ = ["upper_limits.upper_limit"]

src/pyhf/infer/intervals/upper_limits.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Interval estimation"""
2+
23
import numpy as np
34
from scipy.optimize import toms748
45

src/pyhf/infer/mle.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module for Maximum Likelihood Estimation."""
2+
23
from pyhf import get_backend
34
from pyhf.exceptions import UnspecifiedPOI
45

src/pyhf/interpolators/code0.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Piecewise-linear Interpolation. (Code 0)."""
2+
23
import logging
34
import pyhf
45
from pyhf.tensor.manager import get_backend

src/pyhf/interpolators/code1.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Piecewise-Exponential Interpolation (Code 1)."""
2+
23
import logging
34
import math
45
import pyhf

src/pyhf/interpolators/code2.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Quadratic Interpolation (Code 2)."""
2+
23
import logging
34
import pyhf
45
from pyhf.tensor.manager import get_backend

src/pyhf/interpolators/code4.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Polynomial Interpolation (Code 4)."""
2+
23
import logging
34
import math
45
import pyhf

src/pyhf/interpolators/code4p.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Piecewise-Linear + Polynomial Interpolation (Code 4p)."""
2+
23
import logging
34
import pyhf
45
from pyhf.tensor.manager import get_backend

src/pyhf/modifiers/shapesys.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ def _reindex_access_field(self, pdfconfig):
165165

166166
sample_mask = self._shapesys_mask[syst_index][singular_sample_index][0]
167167
access_field_for_syst_and_batch[sample_mask] = selection
168-
self._access_field[
169-
syst_index, batch_index
170-
] = access_field_for_syst_and_batch
168+
self._access_field[syst_index, batch_index] = (
169+
access_field_for_syst_and_batch
170+
)
171171

172172
def _precompute(self):
173173
tensorlib, _ = get_backend()

src/pyhf/modifiers/staterror.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ def finalize(self):
9292
relerrs = default_backend.sum(
9393
[
9494
[
95-
(modifier_data['data']['uncrt'][binnr] / nomsall[binnr]) ** 2
96-
if nomsall[binnr] > 0
97-
else 0.0
95+
(
96+
(modifier_data['data']['uncrt'][binnr] / nomsall[binnr])
97+
** 2
98+
if nomsall[binnr] > 0
99+
else 0.0
100+
)
98101
for binnr in range(len(modifier_data['data']['nom_data']))
99102
]
100103
for modifier_data in self.builder_data[modname].values()
@@ -184,9 +187,9 @@ def _reindex_access_field(self, pdfconfig):
184187

185188
sample_mask = self._staterror_mask[syst_index][singular_sample_index][0]
186189
access_field_for_syst_and_batch[sample_mask] = selection
187-
self._access_field[
188-
syst_index, batch_index
189-
] = access_field_for_syst_and_batch
190+
self._access_field[syst_index, batch_index] = (
191+
access_field_for_syst_and_batch
192+
)
190193

191194
def _precompute(self):
192195
if not self.param_viewer.index_selection:

src/pyhf/optimize/common.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Common Backend Shim to prepare minimization for optimizer."""
2+
23
from pyhf.tensor.manager import get_backend
34
from pyhf.tensor.common import _TensorViewer
45

src/pyhf/optimize/mixins.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Helper Classes for use of automatic differentiation."""
2+
23
import logging
34

45
import numpy as np

src/pyhf/optimize/opt_minuit.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Minuit Optimizer Class."""
2+
23
from pyhf import exceptions
34
from pyhf.optimize.mixins import OptimizerMixin
45
import scipy

src/pyhf/optimize/opt_scipy.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""SciPy Optimizer Class."""
2+
23
from pyhf import exceptions
34
from pyhf.optimize.mixins import OptimizerMixin
45
import scipy

src/pyhf/optimize/opt_tflow.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tensorflow Backend Function Shim."""
2+
23
from pyhf import get_backend
34
import tensorflow as tf
45

src/pyhf/parameters/paramview.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ def extract_index_access(baseviewer, subviewer, indices):
4444

4545
# the transpose is here so that modifier code doesn't have to do it
4646
indices_concatenated = tensorlib.astensor(
47-
tensorlib.einsum('ij->ji', stitched)
48-
if len(tensorlib.shape(stitched)) > 1
49-
else stitched,
47+
(
48+
tensorlib.einsum('ij->ji', stitched)
49+
if len(tensorlib.shape(stitched)) > 1
50+
else stitched
51+
),
5052
dtype='int',
5153
)
5254
return index_selection, stitched, indices_concatenated

src/pyhf/patchset.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
pyhf patchset provides a user-friendly interface for interacting with patchsets.
33
"""
4+
45
import logging
56
import jsonpatch
67
from pyhf import exceptions

src/pyhf/probability.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The probability density function module."""
2+
23
from pyhf import get_backend
34

45
__all__ = ["Independent", "Normal", "Poisson", "Simultaneous"]

src/pyhf/schema/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
See :class:`~pyhf.schema.Schema` for documentation.
33
"""
4+
45
import pathlib
56
import sys
67
from pyhf.schema.loader import load_schema

src/pyhf/tensor/numpy_backend.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""NumPy Tensor Library Module."""
2+
23
from __future__ import annotations
34

45
import logging

src/pyhf/tensor/pytorch_backend.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""PyTorch Tensor Library Module."""
2+
23
import torch
34
import torch.autograd
45
from torch.distributions.utils import broadcast_all

src/pyhf/tensor/tensorflow_backend.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tensorflow Tensor Library Module."""
2+
23
import logging
34
import tensorflow as tf
45
import tensorflow_probability as tfp

0 commit comments

Comments
 (0)