From a510698c64be954c1da88e63f4e4a207f9b652bf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 19:42:54 +0000 Subject: [PATCH 1/3] chore: update pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) - [github.com/asottile/setup-cfg-fmt: v2.4.0 → v2.5.0](https://github.com/asottile/setup-cfg-fmt/compare/v2.4.0...v2.5.0) - [github.com/psf/black-pre-commit-mirror: 23.9.1 → 23.10.0](https://github.com/psf/black-pre-commit-mirror/compare/23.9.1...23.10.0) - [github.com/astral-sh/ruff-pre-commit: v0.0.291 → v0.1.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.291...v0.1.1) - [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](https://github.com/codespell-project/codespell/compare/v2.2.5...v2.2.6) - [github.com/shellcheck-py/shellcheck-py: v0.9.0.5 → v0.9.0.6](https://github.com/shellcheck-py/shellcheck-py/compare/v0.9.0.5...v0.9.0.6) - [github.com/asottile/pyupgrade: v3.13.0 → v3.15.0](https://github.com/asottile/pyupgrade/compare/v3.13.0...v3.15.0) --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8da43c2dfa..569c621083 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ ci: exclude: ^(docs|studies|tests/samples|src/awkward/_typeparser/generated_parser.py) 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,13 +22,13 @@ repos: args: ["--pytest-test-first"] - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.4.0 + rev: v2.5.0 hooks: - id: setup-cfg-fmt args: [--include-version-classifiers, --max-py-version=3.11] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.9.1 + rev: 23.10.0 hooks: - id: black @@ -39,13 +39,13 @@ repos: additional_dependencies: [pyyaml] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.291 + rev: v0.1.1 hooks: - id: ruff args: ["--fix", "--show-fixes"] - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell args: ["-L", "ue,subjet,parms,fo,numer,thre"] @@ -59,7 +59,7 @@ repos: exclude: .pre-commit-config.yaml - repo: https://github.com/shellcheck-py/shellcheck-py - rev: "v0.9.0.5" + rev: "v0.9.0.6" hooks: - id: shellcheck @@ -74,7 +74,7 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.13.0 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py38-plus] From acba884a5824de00d4f3728ace9b9940b966820c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 19:43:48 +0000 Subject: [PATCH 2/3] style: pre-commit fixes --- dev/generate-tests.py | 12 +++--------- src/awkward/_connect/numpy.py | 6 ++---- src/awkward/_do.py | 18 ++++++------------ src/awkward/_errors.py | 6 ++---- src/awkward/contents/content.py | 4 +--- src/awkward/operations/ak_unflatten.py | 4 ++-- 6 files changed, 16 insertions(+), 34 deletions(-) diff --git a/dev/generate-tests.py b/dev/generate-tests.py index 3e678c923f..63ef72d275 100644 --- a/dev/generate-tests.py +++ b/dev/generate-tests.py @@ -368,9 +368,7 @@ def genspectests(specdict): if isinstance(val, list): f.write( " " * 4 - + "assert {0}[:len(pytest_{0})] == pytest.approx(pytest_{0})\n".format( - arg - ) + + f"assert {arg}[:len(pytest_{arg})] == pytest.approx(pytest_{arg})\n" ) else: f.write(" " * 4 + f"assert {arg} == pytest_{arg}\n") @@ -516,9 +514,7 @@ def gencpukerneltests(specdict): if isinstance(val, list): f.write( " " * 4 - + "assert {0}[:len(pytest_{0})] == pytest.approx(pytest_{0})\n".format( - arg - ) + + f"assert {arg}[:len(pytest_{arg})] == pytest.approx(pytest_{arg})\n" ) else: f.write(" " * 4 + f"assert {arg} == pytest_{arg}\n") @@ -735,9 +731,7 @@ def gencudakerneltests(specdict): if isinstance(val, list): f.write( " " * 4 - + "assert cupy.array_equal({0}[:len(pytest_{0})], cupy.array(pytest_{0}))\n".format( - arg - ) + + f"assert cupy.array_equal({arg}[:len(pytest_{arg})], cupy.array(pytest_{arg}))\n" ) else: f.write(" " * 4 + f"assert {arg} == pytest_{arg}\n") diff --git a/src/awkward/_connect/numpy.py b/src/awkward/_connect/numpy.py index a597f93a64..282b3fef6a 100644 --- a/src/awkward/_connect/numpy.py +++ b/src/awkward/_connect/numpy.py @@ -357,10 +357,8 @@ def action(inputs, **ignore): for x in contents ): raise TypeError( - "{}.{} is not implemented for string types. " - "To register an implementation, add a name to these string(s) and register a behavior overload".format( - type(ufunc).__module__, ufunc.__name__ - ) + f"{type(ufunc).__module__}.{ufunc.__name__} is not implemented for string types. " + "To register an implementation, add a name to these string(s) and register a behavior overload" ) if ufunc is numpy.matmul: diff --git a/src/awkward/_do.py b/src/awkward/_do.py index f1983dd5f8..e30af1bbe2 100644 --- a/src/awkward/_do.py +++ b/src/awkward/_do.py @@ -162,10 +162,8 @@ def unique(layout: Content, axis=None): ) if negaxis > depth: raise AxisError( - "cannot use axis={} on a nested list structure that splits into " - "different depths, the minimum of which is depth={} from the leaves".format( - axis, depth - ) + f"cannot use axis={axis} on a nested list structure that splits into " + f"different depths, the minimum of which is depth={depth} from the leaves" ) else: if negaxis <= 0: @@ -368,10 +366,8 @@ def argsort( ) if negaxis > depth: raise ValueError( - "cannot use axis={} on a nested list structure that splits into " - "different depths, the minimum of which is depth={} from the leaves".format( - axis, depth - ) + f"cannot use axis={axis} on a nested list structure that splits into " + f"different depths, the minimum of which is depth={depth} from the leaves" ) else: if negaxis <= 0: @@ -409,10 +405,8 @@ def sort( ) if negaxis > depth: raise ValueError( - "cannot use axis={} on a nested list structure that splits into " - "different depths, the minimum of which is depth={} from the leaves".format( - axis, depth - ) + f"cannot use axis={axis} on a nested list structure that splits into " + f"different depths, the minimum of which is depth={depth} from the leaves" ) else: if negaxis <= 0: diff --git a/src/awkward/_errors.py b/src/awkward/_errors.py index f757ab7302..8877ed66ef 100644 --- a/src/awkward/_errors.py +++ b/src/awkward/_errors.py @@ -410,14 +410,12 @@ def deprecate( date = "" else: date = " (target date: " + date + ")" - warning = """In version {}{}, this will be {}. + warning = f"""In version {version}{date}, this will be {will_be}. To raise these warnings as errors (and get stack traces to find out where they're called), run import warnings warnings.filterwarnings("error", module="awkward.*") after the first `import awkward` or use `@pytest.mark.filterwarnings("error:::awkward.*")` in pytest. -Issue: {}.""".format( - version, date, will_be, message - ) +Issue: {message}.""" warnings.warn(warning, category, stacklevel=stacklevel + 1) diff --git a/src/awkward/contents/content.py b/src/awkward/contents/content.py index a41a2514d1..4ad34d5152 100644 --- a/src/awkward/contents/content.py +++ b/src/awkward/contents/content.py @@ -498,9 +498,7 @@ def _getitem_next_missing( ) else: raise NotImplementedError( - "FIXME: unhandled case of SliceMissing with RecordArray containing {}".format( - content - ) + f"FIXME: unhandled case of SliceMissing with RecordArray containing {content}" ) return ak.contents.RecordArray( diff --git a/src/awkward/operations/ak_unflatten.py b/src/awkward/operations/ak_unflatten.py index cdded04853..17d8be6725 100644 --- a/src/awkward/operations/ak_unflatten.py +++ b/src/awkward/operations/ak_unflatten.py @@ -160,7 +160,7 @@ def unflatten_this_layout(layout): ): raise ValueError( "structure imposed by 'counts' does not fit in the array or partition " - "at axis={}".format(axis) + f"at axis={axis}" ) offsets = current_offsets[: position + 1] @@ -214,7 +214,7 @@ def apply(layout, depth, **kwargs): ): raise ValueError( "structure imposed by 'counts' does not fit in the array or partition " - "at axis={}".format(axis) + f"at axis={axis}" ) positions[0] = 0 From c22aa5a9673ce5cda02a45dea27a3449fd18ccf5 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Mon, 23 Oct 2023 22:44:18 +0100 Subject: [PATCH 3/3] chore: appease linter --- CONTRIBUTING.md | 2 +- awkward-cpp/src/libawkward/forth/ForthMachine.cpp | 2 +- src/awkward/operations/ak_copy.py | 2 +- tests/test_1762_jax_behavior_support.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 491d327a4b..4d94a44e2c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -80,7 +80,7 @@ nox -s prepare -- --tests --docs ``` This can reduce the time taken to perform the preparation step in the event that only the package-building step is needed. -`nox` also lets us re-use the virtualenvs that it creates for each session with the `-R` flag, eliminating the dependency reinstall time: +`nox` also lets us reuse the virtualenvs that it creates for each session with the `-R` flag, eliminating the dependency reinstall time: ```bash nox -R -s prepare ``` diff --git a/awkward-cpp/src/libawkward/forth/ForthMachine.cpp b/awkward-cpp/src/libawkward/forth/ForthMachine.cpp index 45dad4b04a..7393547781 100644 --- a/awkward-cpp/src/libawkward/forth/ForthMachine.cpp +++ b/awkward-cpp/src/libawkward/forth/ForthMachine.cpp @@ -120,7 +120,7 @@ namespace awkward { const std::set reserved_words_({ // comments "(", ")", "\\", "\n", "", - // defining functinos + // defining functions ":", ";", "recurse", // declaring globals "variable", "input", "output", diff --git a/src/awkward/operations/ak_copy.py b/src/awkward/operations/ak_copy.py index 07269e9697..0d0e70669e 100644 --- a/src/awkward/operations/ak_copy.py +++ b/src/awkward/operations/ak_copy.py @@ -54,7 +54,7 @@ def copy(array): This is key to Awkward Array's efficiency (memory and speed): operations that - only change part of a structure re-use pieces from the original ("structural + only change part of a structure reuse pieces from the original ("structural sharing"). Changing data in-place would result in many surprising long-distance changes, so we don't support it. However, an #ak.Array's data might come from a mutable third-party library, so this function allows you to make a true copy. diff --git a/tests/test_1762_jax_behavior_support.py b/tests/test_1762_jax_behavior_support.py index aa76777cee..d0c4207b33 100644 --- a/tests/test_1762_jax_behavior_support.py +++ b/tests/test_1762_jax_behavior_support.py @@ -42,7 +42,7 @@ def test_jvp_nested_list(): def func(x): return x[::-1] ** 2 - # TODO: enable leak checing + # TODO: enable leak checking # with jax.checking_leaks(): value_jvp, jvp_grad = jax.jvp(func, (array,), (tangent,)) assert value_jvp.to_list() == [[1.0, 4.0, 9.0, 16.0, 25.0]]