From b6e51f02e08f22dc2a63a11e5e1cf694c972fb46 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 5 Jan 2024 01:50:23 -0600 Subject: [PATCH 1/5] chore(backport): Update pre-commit hooks --- .pre-commit-config.yaml | 26 ++++++++++++++------------ pyproject.toml | 1 + 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1087037b32..92d2a4223b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -22,29 +22,38 @@ repos: - id: name-tests-test args: ["--pytest-test-first"] - id: requirements-txt-fixer + exclude: tests/constraints.txt - id: trailing-whitespace # exclude generated files exclude: ^validation/|\.dtd$|\.xml$ +- repo: https://github.com/pre-commit/pygrep-hooks + rev: "v1.10.0" + hooks: + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal + - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.292" + rev: "v0.1.9" hooks: - id: ruff args: ["--fix", "--show-fixes"] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.9.1 + rev: 23.12.1 hooks: - id: black-jupyter + types_or: [python, pyi, jupyter] - repo: https://github.com/adamchainz/blacken-docs rev: 1.16.0 hooks: - id: blacken-docs - additional_dependencies: [black==23.7.0] + additional_dependencies: [black==23.12.1] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.5.1 + rev: v1.8.0 # check the oldest and newest supported Pythons hooks: - &mypy @@ -58,13 +67,6 @@ repos: name: mypy with Python 3.11 args: ["--python-version=3.11"] -- repo: https://github.com/nbQA-dev/nbQA - rev: 1.7.0 - hooks: - - id: nbqa-ruff - additional_dependencies: [ruff==0.0.292] - args: ["--extend-ignore=F821,F401,F841,F811"] - - repo: https://github.com/codespell-project/codespell rev: v2.2.6 hooks: diff --git a/pyproject.toml b/pyproject.toml index 5468bc8847..fd42ccdffb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -298,3 +298,4 @@ flake8-tidy-imports.ban-relative-imports = "all" [tool.ruff.per-file-ignores] "docs/lite/jupyterlite.py" = ["F401", "F704"] +"**.ipynb" = ["F821", "F401", "F841", "F811", "E703"] From 7d610266bf693dba5865ec1f2ca414e2a4166025 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 5 Jan 2024 01:51:16 -0600 Subject: [PATCH 2/5] backport backticks fix --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 278abc2447..fbb5bf9925 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ .. pyhf documentation master file, created by sphinx-quickstart on Fri Feb 9 11:58:49 2018. You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. + contain the root ``toctree`` directive. .. toctree:: :hidden: From 9f7b89546037579f962b4b55de8c1ac8c99afaf3 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Thu, 4 Jan 2024 16:39:54 -0600 Subject: [PATCH 3/5] chore: Remove Mypy 'show_error_codes' as now default (#2414) * sp-repo-review MY102: Mypy show_error_codes deprecated Must not have show_error_codes. Use hide_error_codes instead (since Mypy v0.990). --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fd42ccdffb..331ff84575 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -229,7 +229,6 @@ files = "src" python_version = "3.11" warn_unused_configs = true strict = true -show_error_codes = true enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] warn_unreachable = true From dbab4dfb855feb039a5aca890d4a68746b11fb4a Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 17 Nov 2023 08:35:34 -0600 Subject: [PATCH 4/5] chore: Use Ruff lint config (#2381) * Use the Ruff lint config option as recommended in the Scientific Python Development Guide. - RF202: Use (new) lint config section. - c.f. https://learn.scientific-python.org/development/guides/style/#ruff --- pyproject.toml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 331ff84575..07590c4df5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -275,26 +275,28 @@ module = [ ignore_errors = true [tool.ruff] +src = ["src"] +line-length = 88 + +[tool.ruff.lint] select = [ "E", "F", "W", # flake8 "UP", # pyupgrade "RUF", # Ruff-specific "TID", # flake8-tidy-imports ] -line-length = 88 ignore = [ "E402", "E501", "RUF001", # String contains ambiguous unicode character "RUF005", # unpack-instead-of-concatenating-to-collection-literal ] -src = ["src"] typing-modules = ["pyhf.typing"] unfixable = [ "F841", # Removes unused variables ] flake8-tidy-imports.ban-relative-imports = "all" -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "docs/lite/jupyterlite.py" = ["F401", "F704"] "**.ipynb" = ["F821", "F401", "F841", "F811", "E703"] From df5d96c92d40a03e7fe72a298be2d6495f1a744e Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Fri, 5 Jan 2024 02:09:50 -0600 Subject: [PATCH 5/5] backport ignores --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 07590c4df5..156f5ba4b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -222,6 +222,8 @@ filterwarnings = [ 'ignore:Call to deprecated create function:DeprecationWarning', # protobuf via tensorflow 'ignore:`np.bool8` is a deprecated alias for `np.bool_`:DeprecationWarning', # numpy via tensorflow "ignore:module 'sre_constants' is deprecated:DeprecationWarning", # tensorflow v2.12.0+ for Python 3.11+ + "ignore:ml_dtypes.float8_e4m3b11 is deprecated.", #FIXME: Can remove when jaxlib>=0.4.12 + "ignore:Skipping device Apple Paravirtual device that does not support Metal 2.0:UserWarning", # Can't fix given hardware/virtualized device ] [tool.mypy]