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 #1345

Merged
merged 4 commits into from
Dec 20, 2024
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.8.3
hooks:
- id: ruff
args: [--fix, --show-fixes]
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/interpretation/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def __init__(self, model, members, original=None):
member, value = members[i]
if member is not None and not all_headers_prepended:
all_headers_prepended = True
if member is None and all_headers_prepended or len(members) == 1:
if (member is None and all_headers_prepended) or len(members) == 1:
all_headers_prepended = False
del members[i]

Expand Down
8 changes: 4 additions & 4 deletions src/uproot/language/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,13 @@ def getter(name):
if is_pandas:
pandas = uproot.extras.pandas()

for name in output:
for name, data in output.items():
if (
is_pandas
and isinstance(cut.index, pandas.MultiIndex)
and not isinstance(output[name].index, pandas.MultiIndex)
and not isinstance(data.index, pandas.MultiIndex)
):
original = output[name]
original = data
modified = pandas.DataFrame(
{original.name: original.values},
index=pandas.MultiIndex.from_arrays(
Expand All @@ -514,7 +514,7 @@ def getter(name):
output[name] = selected[original.name]

else:
output[name] = output[name][cut]
output[name] = data[cut]

# clear dicts to get rid of big arrays.
# note: without this these arrays are not properly released from memory!
Expand Down
8 changes: 4 additions & 4 deletions src/uproot/reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,7 @@ def title_of(self, where, recursive=True):

Note that this does not read any data from the file.
"""
if recursive and "/" in where or ":" in where:
if (recursive and "/" in where) or ":" in where:
step, last_item = self.descent_into_path(where)
return step[last_item].title
else:
Expand All @@ -1965,7 +1965,7 @@ def classname_of(self, where, encoded=False, version=None, recursive=True):
Note that this does not read any data from the file.
"""

if recursive and "/" in where or ":" in where:
if (recursive and "/" in where) or ":" in where:
step, last_item = self.descent_into_path(where)
return step[last_item].classname
else:
Expand All @@ -1987,7 +1987,7 @@ def class_of(self, where, version=None, recursive=True):

Note that this does not read any data from the file.
"""
if recursive and "/" in where or ":" in where:
if (recursive and "/" in where) or ":" in where:
return self._file.class_named(
self.classname_of(where, version=version), version=version
)
Expand All @@ -2009,7 +2009,7 @@ def streamer_of(self, where, version="max", recursive=True):

Note that this does not read any data from the file.
"""
if recursive and "/" in where or ":" in where:
if (recursive and "/" in where) or ":" in where:
return self._file.streamer_named(
self.classname_of(where, version=version), version=version
)
Expand Down
4 changes: 2 additions & 2 deletions src/uproot/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def bytestring(data):
"""
length = len(data)
if length < 255:
return struct.pack(">B%ds" % length, length, data)
return struct.pack(f">B{length}s", length, data)
else:
return struct.pack(">BI%ds" % length, 255, length, data)
return struct.pack(f">BI{length}s", 255, length, data)


def numbytes_version(num_bytes, version):
Expand Down
14 changes: 7 additions & 7 deletions src/uproot/writing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
)

__all__ = [
"WritableBranch",
"WritableDirectory",
"WritableFile",
"WritableTree",
"create",
"dask_write",
"recreate",
"to_TArray",
"to_TH1x",
"to_TH2x",
Expand All @@ -45,12 +52,5 @@
"to_TProfile2D",
"to_TProfile3D",
"to_writable",
"WritableDirectory",
"WritableFile",
"WritableTree",
"WritableBranch",
"create",
"recreate",
"update",
"dask_write",
]
10 changes: 4 additions & 6 deletions src/uproot/writing/_cascadetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,22 +1098,20 @@ def write_anew(self, sink):
out.append(uproot._util.tobytes(leaf_header))
if len(leaf_name) < 255:
out.append(
struct.pack(">B%ds" % len(leaf_name), len(leaf_name), leaf_name)
struct.pack(f">B{len(leaf_name)}s", len(leaf_name), leaf_name)
)
else:
out.append(
struct.pack(
">BI%ds" % len(leaf_name), 255, len(leaf_name), leaf_name
)
struct.pack(f">BI{len(leaf_name)}s", 255, len(leaf_name), leaf_name)
)
if len(leaf_title) < 255:
out.append(
struct.pack(">B%ds" % len(leaf_title), len(leaf_title), leaf_title)
struct.pack(f">B{len(leaf_title)}s", len(leaf_title), leaf_title)
)
else:
out.append(
struct.pack(
">BI%ds" % len(leaf_title), 255, len(leaf_title), leaf_title
f">BI{len(leaf_title)}s", 255, len(leaf_title), leaf_title
)
)

Expand Down
Loading