Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(backport): Update pre-commit hooks #2150

Merged
merged 3 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -27,7 +27,7 @@ repos:
exclude: ^validation/|\.dtd$|\.xml$

- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]
Expand All @@ -38,51 +38,54 @@ repos:
- id: absolufy-imports

- repo: https://github.com/psf/black
rev: 22.8.0
rev: 23.1.0
hooks:
- id: black-jupyter

- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies: [black==22.8.0]
additional_dependencies: [black==23.1.0]

- repo: https://github.com/asottile/yesqa
rev: v1.4.0
hooks:
- id: yesqa

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8
args: ["--count", "--statistics"]
additional_dependencies: [flake8-encodings==0.5.0.post1]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.971
rev: v1.0.1
# check the oldest and newest supported Pythons
# Though use Python 3.8 as the oldest Python to run mypy
# to avoid positional-only errors from NumPy in Python 3.11
# runtime.
hooks:
- &mypy
id: mypy
name: mypy with Python 3.7
name: mypy with Python 3.8
files: src
additional_dependencies:
['numpy', 'types-tqdm', 'click', 'types-jsonpatch', 'types-pyyaml', 'types-jsonschema', 'importlib_metadata', 'packaging']
args: ["--python-version=3.7"]
args: ["--python-version=3.8"]
- <<: *mypy
name: mypy with Python 3.10
args: ["--python-version=3.10"]
name: mypy with Python 3.11
args: ["--python-version=3.11"]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.4.0
rev: 1.6.3
hooks:
- id: nbqa-pyupgrade
additional_dependencies: [pyupgrade==2.37.3]
additional_dependencies: [pyupgrade==3.3.1]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.1
rev: v2.2.2
hooks:
- id: codespell
files: ^.*\.(py|md|rst)$
Expand Down
2 changes: 0 additions & 2 deletions docs/exts/xref.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ def xref(typ, rawtext, text, lineno, inliner, options=None, content=None):


def get_refs(app):

xref.links = app.config.xref_links


def setup(app):

app.add_config_value('xref_links', {}, True)
app.add_role('xref', xref)
app.connect("builder-inited", get_refs)
1 change: 0 additions & 1 deletion src/pyhf/modifiers/normsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class normsys_combined:
def __init__(
self, modifiers, pdfconfig, builder_data, interpcode='code1', batch_size=None
):

self.interpcode = interpcode
assert self.interpcode in ['code1', 'code4']

Expand Down
1 change: 0 additions & 1 deletion src/pyhf/modifiers/staterror.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ class staterror_combined:
op_code = 'multiplication'

def __init__(self, modifiers, pdfconfig, builder_data, batch_size=None):

default_backend = pyhf.default_backend
self.batch_size = batch_size

Expand Down
1 change: 0 additions & 1 deletion src/pyhf/optimize/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def _internal_minimize(
options={},
par_names=None,
):

minimizer = self._get_minimizer(
func,
x0,
Expand Down
2 changes: 0 additions & 2 deletions src/pyhf/optimize/opt_minuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def _get_minimizer(
do_grad=False,
par_names=None,
):

fixed_vals = fixed_vals or []
# Minuit wants True/False for each parameter
fixed_bools = [False] * len(init_pars)
Expand Down Expand Up @@ -82,7 +81,6 @@ def _minimize(
fixed_vals=None,
options={},
):

"""
Same signature as :func:`scipy.optimize.minimize`.

Expand Down
1 change: 0 additions & 1 deletion src/pyhf/parameters/paramview.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class ParamViewer:
"""

def __init__(self, shape, par_map, par_selection):

default_backend = pyhf.default_backend

batch_size = shape[0] if len(shape) > 1 else None
Expand Down
4 changes: 2 additions & 2 deletions src/pyhf/tensor/numpy_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ def outer(self, tensor_in_1: Tensor[T], tensor_in_2: Tensor[T]) -> ArrayLike:
return np.outer(tensor_in_1, tensor_in_2) # type: ignore[arg-type]

def gather(self, tensor: Tensor[T], indices: NDArray[np.integer[T]]) -> ArrayLike:
return tensor[indices] # type: ignore[no-any-return]
return tensor[indices]

def boolean_mask(self, tensor: Tensor[T], mask: NDArray[np.bool_]) -> ArrayLike:
return tensor[mask] # type: ignore[no-any-return]
return tensor[mask]

def isfinite(self, tensor: Tensor[T]) -> NDArray[np.bool_]:
return np.isfinite(tensor)
Expand Down
2 changes: 0 additions & 2 deletions tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ def test_import_histosys():


def test_import_filecache(mocker):

mocker.patch("pyhf.readxml.uproot.open", wraps=uproot.open)

pyhf.readxml.clear_filecache()
Expand Down Expand Up @@ -458,7 +457,6 @@ def test_process_modifiers(mocker, caplog):


def test_import_validation_exception(mocker, caplog):

mocker.patch(
'pyhf.schema.validate',
side_effect=pyhf.exceptions.InvalidSpecification(
Expand Down
1 change: 0 additions & 1 deletion validation/standard_hypo_test_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def standard_hypo_test_demo(
sb_model_name="ModelConfig",
data_name="obsData",
):

file = ROOT.TFile.Open(infile)
workspace = file.Get(workspace_name)
sb_model = workspace.obj(sb_model_name)
Expand Down