Skip to content

Commit 89223b8

Browse files
chore: update pre-commit hooks (#1345)
* chore: update pre-commit hooks updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.4 → v0.8.3](astral-sh/ruff-pre-commit@v0.7.4...v0.8.3) * style: pre-commit fixes * Fixed linter errors --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Andres Rios Tascon <ariostas@gmail.com>
1 parent 4ee1a2d commit 89223b8

File tree

7 files changed

+23
-25
lines changed

7 files changed

+23
-25
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
- id: black
2424

2525
- repo: https://github.com/astral-sh/ruff-pre-commit
26-
rev: v0.7.4
26+
rev: v0.8.3
2727
hooks:
2828
- id: ruff
2929
args: [--fix, --show-fixes]

src/uproot/interpretation/objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def __init__(self, model, members, original=None):
758758
member, value = members[i]
759759
if member is not None and not all_headers_prepended:
760760
all_headers_prepended = True
761-
if member is None and all_headers_prepended or len(members) == 1:
761+
if (member is None and all_headers_prepended) or len(members) == 1:
762762
all_headers_prepended = False
763763
del members[i]
764764

src/uproot/language/python.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,13 +497,13 @@ def getter(name):
497497
if is_pandas:
498498
pandas = uproot.extras.pandas()
499499

500-
for name in output:
500+
for name, data in output.items():
501501
if (
502502
is_pandas
503503
and isinstance(cut.index, pandas.MultiIndex)
504-
and not isinstance(output[name].index, pandas.MultiIndex)
504+
and not isinstance(data.index, pandas.MultiIndex)
505505
):
506-
original = output[name]
506+
original = data
507507
modified = pandas.DataFrame(
508508
{original.name: original.values},
509509
index=pandas.MultiIndex.from_arrays(
@@ -514,7 +514,7 @@ def getter(name):
514514
output[name] = selected[original.name]
515515

516516
else:
517-
output[name] = output[name][cut]
517+
output[name] = data[cut]
518518

519519
# clear dicts to get rid of big arrays.
520520
# note: without this these arrays are not properly released from memory!

src/uproot/reading.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,7 +1943,7 @@ def title_of(self, where, recursive=True):
19431943
19441944
Note that this does not read any data from the file.
19451945
"""
1946-
if recursive and "/" in where or ":" in where:
1946+
if (recursive and "/" in where) or ":" in where:
19471947
step, last_item = self.descent_into_path(where)
19481948
return step[last_item].title
19491949
else:
@@ -1965,7 +1965,7 @@ def classname_of(self, where, encoded=False, version=None, recursive=True):
19651965
Note that this does not read any data from the file.
19661966
"""
19671967

1968-
if recursive and "/" in where or ":" in where:
1968+
if (recursive and "/" in where) or ":" in where:
19691969
step, last_item = self.descent_into_path(where)
19701970
return step[last_item].classname
19711971
else:
@@ -1987,7 +1987,7 @@ def class_of(self, where, version=None, recursive=True):
19871987
19881988
Note that this does not read any data from the file.
19891989
"""
1990-
if recursive and "/" in where or ":" in where:
1990+
if (recursive and "/" in where) or ":" in where:
19911991
return self._file.class_named(
19921992
self.classname_of(where, version=version), version=version
19931993
)
@@ -2009,7 +2009,7 @@ def streamer_of(self, where, version="max", recursive=True):
20092009
20102010
Note that this does not read any data from the file.
20112011
"""
2012-
if recursive and "/" in where or ":" in where:
2012+
if (recursive and "/" in where) or ":" in where:
20132013
return self._file.streamer_named(
20142014
self.classname_of(where, version=version), version=version
20152015
)

src/uproot/serialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def bytestring(data):
3737
"""
3838
length = len(data)
3939
if length < 255:
40-
return struct.pack(">B%ds" % length, length, data)
40+
return struct.pack(f">B{length}s", length, data)
4141
else:
42-
return struct.pack(">BI%ds" % length, 255, length, data)
42+
return struct.pack(f">BI{length}s", 255, length, data)
4343

4444

4545
def numbytes_version(num_bytes, version):

src/uproot/writing/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
)
3636

3737
__all__ = [
38+
"WritableBranch",
39+
"WritableDirectory",
40+
"WritableFile",
41+
"WritableTree",
42+
"create",
43+
"dask_write",
44+
"recreate",
3845
"to_TArray",
3946
"to_TH1x",
4047
"to_TH2x",
@@ -45,12 +52,5 @@
4552
"to_TProfile2D",
4653
"to_TProfile3D",
4754
"to_writable",
48-
"WritableDirectory",
49-
"WritableFile",
50-
"WritableTree",
51-
"WritableBranch",
52-
"create",
53-
"recreate",
5455
"update",
55-
"dask_write",
5656
]

src/uproot/writing/_cascadetree.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,22 +1098,20 @@ def write_anew(self, sink):
10981098
out.append(uproot._util.tobytes(leaf_header))
10991099
if len(leaf_name) < 255:
11001100
out.append(
1101-
struct.pack(">B%ds" % len(leaf_name), len(leaf_name), leaf_name)
1101+
struct.pack(f">B{len(leaf_name)}s", len(leaf_name), leaf_name)
11021102
)
11031103
else:
11041104
out.append(
1105-
struct.pack(
1106-
">BI%ds" % len(leaf_name), 255, len(leaf_name), leaf_name
1107-
)
1105+
struct.pack(f">BI{len(leaf_name)}s", 255, len(leaf_name), leaf_name)
11081106
)
11091107
if len(leaf_title) < 255:
11101108
out.append(
1111-
struct.pack(">B%ds" % len(leaf_title), len(leaf_title), leaf_title)
1109+
struct.pack(f">B{len(leaf_title)}s", len(leaf_title), leaf_title)
11121110
)
11131111
else:
11141112
out.append(
11151113
struct.pack(
1116-
">BI%ds" % len(leaf_title), 255, len(leaf_title), leaf_title
1114+
f">BI{len(leaf_title)}s", 255, len(leaf_title), leaf_title
11171115
)
11181116
)
11191117

0 commit comments

Comments
 (0)