Skip to content

Commit

Permalink
chore: update pre-commit hooks (#3050)
Browse files Browse the repository at this point in the history
* chore: update pre-commit hooks

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.3](astral-sh/ruff-pre-commit@v0.2.2...v0.3.3)
- [github.com/shellcheck-py/shellcheck-py: v0.9.0.6 → v0.10.0.1](shellcheck-py/shellcheck-py@v0.9.0.6...v0.10.0.1)
- [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](pre-commit/mirrors-mypy@v1.8.0...v1.9.0)

* style: pre-commit fixes

* disable PyLint so that it doesn't fight with either black or ruff

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jim Pivarski <jpivarski@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] and jpivarski committed Mar 21, 2024
1 parent a6444b0 commit 7220953
Show file tree
Hide file tree
Showing 56 changed files with 272 additions and 625 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repos:
additional_dependencies: [pyyaml]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
rev: v0.3.3
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand All @@ -48,7 +48,7 @@ repos:
exclude: .pre-commit-config.yaml

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.9.0.6"
rev: "v0.10.0.1"
hooks:
- id: shellcheck

Expand All @@ -68,7 +68,7 @@ repos:
args: ["--verbose"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.9.0
hooks:
- id: mypy
files: src
Expand Down
34 changes: 8 additions & 26 deletions dev/generate-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,7 @@ def gencpukerneltests(specdict):
elif count == 2:
f.write(
" " * 4
+ "{0} = ctypes.pointer(ctypes.cast((ctypes.c_{1}*len({0}[0]))(*{0}[0]),ctypes.POINTER(ctypes.c_{1})))\n".format(
arg, typename
)
+ f"{arg} = ctypes.pointer(ctypes.cast((ctypes.c_{typename}*len({arg}[0]))(*{arg}[0]),ctypes.POINTER(ctypes.c_{typename})))\n"
)
f.write(" " * 4 + "funcC = getattr(lib, '" + spec.name + "')\n")
args = ""
Expand Down Expand Up @@ -635,9 +633,7 @@ def gencpuunittests(specdict):
elif count == 2:
f.write(
" " * 4
+ "{0} = ctypes.pointer(ctypes.cast((ctypes.c_{1}*len({0}[0]))(*{0}[0]),ctypes.POINTER(ctypes.c_{1})))\n".format(
arg, typename
)
+ f"{arg} = ctypes.pointer(ctypes.cast((ctypes.c_{typename}*len({arg}[0]))(*{arg}[0]),ctypes.POINTER(ctypes.c_{typename})))\n"
)
for arg, val in test["inputs"].items():
typename = remove_const(
Expand All @@ -660,9 +656,7 @@ def gencpuunittests(specdict):
elif count == 2:
f.write(
" " * 4
+ "{0} = ctypes.pointer(ctypes.cast((ctypes.c_{1}*len({0}[0]))(*{0}[0]),ctypes.POINTER(ctypes.c_{1})))\n".format(
arg, typename
)
+ f"{arg} = ctypes.pointer(ctypes.cast((ctypes.c_{typename}*len({arg}[0]))(*{arg}[0]),ctypes.POINTER(ctypes.c_{typename})))\n"
)

f.write(" " * 4 + "funcC = getattr(lib, '" + spec.name + "')\n")
Expand Down Expand Up @@ -882,9 +876,7 @@ def gencudakerneltests(specdict):
if count == 1:
f.write(
" " * 4
+ "{} = cupy.array({}, dtype=cupy.{})\n".format(
arg, val, typename
)
+ f"{arg} = cupy.array({val}, dtype=cupy.{typename})\n"
)
dtypes.append("cupy." + typename)
elif count == 2:
Expand Down Expand Up @@ -1023,18 +1015,12 @@ def gencudaunittests(specdict):
if count == 1:
f.write(
" " * 4
+ "{} = cupy.array({}, dtype=cupy.{})\n".format(
arg,
[gettypeval(typename)] * len(val),
typename,
)
+ f"{arg} = cupy.array({[gettypeval(typename)] * len(val)}, dtype=cupy.{typename})\n"
)
elif count == 2:
f.write(
" " * 4
+ "{} = cupy.array({}, dtype=cupy.{})\n".format(
arg, val, typename
)
+ f"{arg} = cupy.array({val}, dtype=cupy.{typename})\n"
)
for arg, val in test["inputs"].items():
typename = remove_const(
Expand All @@ -1056,16 +1042,12 @@ def gencudaunittests(specdict):
if count == 1:
f.write(
" " * 4
+ "{} = cupy.array({}, dtype=cupy.{})\n".format(
arg, val, typename
)
+ f"{arg} = cupy.array({val}, dtype=cupy.{typename})\n"
)
elif count == 2:
f.write(
" " * 4
+ "{} = cupy.array({}, dtype=cupy.{})\n".format(
arg, val, typename
)
+ f"{arg} = cupy.array({val}, dtype=cupy.{typename})\n"
)
cuda_string = (
"funcC = cupy_backend['"
Expand Down
20 changes: 4 additions & 16 deletions src/awkward/_broadcasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,7 @@ def ensure_common_length(inputs, options: BroadcastOptions) -> ShapeItem:
continue
if other_content.length != length:
raise ValueError(
"cannot broadcast {} of length {} with {} of length {}{}".format(
type(content).__name__,
length,
type(other_content).__name__,
other_content.length,
in_function(options),
)
f"cannot broadcast {type(content).__name__} of length {length} with {type(other_content).__name__} of length {other_content.length}{in_function(options)}"
)
return length

Expand Down Expand Up @@ -619,9 +613,7 @@ def broadcast_any_list():
else:
raise ValueError(
"cannot broadcast RegularArray of size "
"{} with RegularArray of size {}{}".format(
x.size, dim_size, in_function(options)
)
f"{x.size} with RegularArray of size {dim_size}{in_function(options)}"
)
else:
nextinputs.append(x)
Expand Down Expand Up @@ -786,12 +778,8 @@ def broadcast_any_union():
continue
elif length != tags.shape[0]:
raise ValueError(
"cannot broadcast UnionArray of length {} "
"with UnionArray of length {}{}".format(
length,
tags.shape[0],
in_function(options),
)
f"cannot broadcast UnionArray of length {length} "
f"with UnionArray of length {tags.shape[0]}{in_function(options)}"
)

tags = backend.index_nplike.empty(length, dtype=np.int8)
Expand Down
4 changes: 1 addition & 3 deletions src/awkward/_connect/numba/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def globalstring(context, builder, pyvalue):
class ArrayBuilderType(numba.types.Type):
def __init__(self, behavior):
super().__init__(
name="ak.ArrayBuilderType({})".format(
ak._connect.numba.arrayview.repr_behavior(behavior)
)
name=f"ak.ArrayBuilderType({ak._connect.numba.arrayview.repr_behavior(behavior)})"
)
self.behavior = behavior

Expand Down
18 changes: 5 additions & 13 deletions src/awkward/_connect/numba/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,8 @@ def find_numba_record_lower(layouttype, behavior):
@numba.extending.typeof_impl.register(ak.record.Record)
def fake_typeof(obj, c):
raise NumbaTypeError(
"{} objects cannot be passed directly into Numba-compiled functions; "
"construct a high-level ak.Array or ak.Record instead".format(
type(obj).__name__
)
f"{type(obj).__name__} objects cannot be passed directly into Numba-compiled functions; "
"construct a high-level ak.Array or ak.Record instead"
)


Expand Down Expand Up @@ -1228,9 +1226,7 @@ def getitem_at(self, viewtype):
if index is None:
if self.fields is None:
raise NumbaValueError(
"no field {} in tuples with {} fields".format(
repr(key), len(self.contenttypes)
)
f"no field {key!r} in tuples with {len(self.contenttypes)} fields"
)
else:
raise NumbaValueError(
Expand All @@ -1249,9 +1245,7 @@ def getitem_field(self, viewtype, key):
if index is None:
if self.fields is None:
raise NumbaValueError(
"no field {} in tuples with {} fields".format(
repr(key), len(self.contenttypes)
)
f"no field {key!r} in tuples with {len(self.contenttypes)} fields"
)
else:
raise NumbaValueError(
Expand All @@ -1268,9 +1262,7 @@ def getitem_field_record(self, recordviewtype, key):
if index is None:
if self.fields is None:
raise NumbaValueError(
"no field {} in tuple with {} fields".format(
repr(key), len(self.contenttypes)
)
f"no field {key!r} in tuple with {len(self.contenttypes)} fields"
)
else:
raise NumbaValueError(
Expand Down
6 changes: 3 additions & 3 deletions src/awkward/_connect/numba/layoutbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,9 +1028,9 @@ def append_end(builder):
builder._current_byte_index[1] += 1
if builder._valid_when:
# 0 indicates null, 1 indicates valid
builder._mask._panels[-1][
builder._mask._length_pos[1] - 1
] = builder._current_byte_index[0]
builder._mask._panels[-1][builder._mask._length_pos[1] - 1] = (
builder._current_byte_index[0]
)
else:
# 0 indicates valid, 1 indicates null
builder._mask._panels[-1][
Expand Down
6 changes: 3 additions & 3 deletions src/awkward/_do.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ def reduce(
)
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/_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class KernelError(Protocol):
class Kernel(Protocol):
@property
@abstractmethod
def key(self) -> KernelKeyType:
...
def key(self) -> KernelKeyType: ...

@abstractmethod
def __call__(self, *args) -> KernelError | None:
Expand Down Expand Up @@ -62,8 +61,7 @@ def __repr__(self):
class CTypesFunc(Protocol):
argtypes: tuple[Any, ...]

def __call__(self, *args) -> Any:
...
def __call__(self, *args) -> Any: ...


class NumpyKernel(BaseKernel):
Expand Down
4 changes: 1 addition & 3 deletions src/awkward/_meta/recordmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ def content(self, index_or_field: int | str) -> T:
index = self.field_to_index(index_or_field)
else:
raise TypeError(
"index_or_field must be an integer (index) or string (field), not {}".format(
repr(index_or_field)
)
f"index_or_field must be an integer (index) or string (field), not {index_or_field!r}"
)
return self._contents[index] # type: ignore[index]
Loading

0 comments on commit 7220953

Please sign in to comment.