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: update pre-commit hooks #2733

Merged
merged 3 commits into from
Oct 23, 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
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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"]
Expand All @@ -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

Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion awkward-cpp/src/libawkward/forth/ForthMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace awkward {
const std::set<std::string> reserved_words_({
// comments
"(", ")", "\\", "\n", "",
// defining functinos
// defining functions
":", ";", "recurse",
// declaring globals
"variable", "input", "output",
Expand Down
12 changes: 3 additions & 9 deletions dev/generate-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 2 additions & 4 deletions src/awkward/_connect/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 6 additions & 12 deletions src/awkward/_do.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions src/awkward/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
4 changes: 1 addition & 3 deletions src/awkward/contents/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/operations/ak_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def copy(array):
<Array [{x: 1}, {x: 2}, {x: 3}] type='3 * {x: int64}'>

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.
Expand Down
4 changes: 2 additions & 2 deletions src/awkward/operations/ak_unflatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/test_1762_jax_behavior_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down