Skip to content

Commit bcb6682

Browse files
committed
fix: support Python before 3.11
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 381f5dc commit bcb6682

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/uproot_browser/tree.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ def is_dir(item: Any) -> bool: # noqa: ARG001
5151
def _(item: uproot.reading.ReadOnlyDirectory) -> Literal[True]: # noqa: ARG001
5252
return True
5353

54+
5455
@is_dir.register
5556
def _(item: uproot.behaviors.TBranch.HasBranches) -> bool:
5657
return len(item.branches) > 0
5758

59+
5860
@is_dir.register
5961
def _(item: uproot.behaviors.RNTuple.HasFields) -> bool:
6062
return len(item.keys()) > 0
@@ -155,8 +157,12 @@ def _process_item_tfile(
155157
)
156158

157159

158-
@process_item.register
159-
def _process_item_ttree(uproot_object: uproot.TTree | uproot.behaviors.RNTuple.RNTuple) -> MetaDict:
160+
# Python 3.11 can just use `|` directly for register
161+
@process_item.register(uproot.TTree)
162+
@process_item.register(uproot.behaviors.RNTuple.RNTuple)
163+
def _process_item_ttree(
164+
uproot_object: uproot.TTree | uproot.behaviors.RNTuple.RNTuple,
165+
) -> MetaDict:
160166
"""
161167
Given an tree, return a rich.tree.Tree output.
162168
"""

0 commit comments

Comments
 (0)