File tree Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change 6
6
7
7
import dataclasses
8
8
import functools
9
- from collections .abc import Mapping
9
+ from collections .abc import Iterable
10
10
from pathlib import Path
11
- from typing import Any , Literal , TypedDict
11
+ from typing import Any , Literal , Protocol , TypedDict
12
12
13
13
import uproot
14
14
import uproot .reading
29
29
)
30
30
31
31
32
+ class SupportsRecursiveKeys (Protocol ):
33
+ def keys (self , recursive : bool = True ) -> Iterable [str ]: ...
34
+
35
+
32
36
def __dir__ () -> tuple [str , ...]:
33
37
return __all__
34
38
@@ -53,21 +57,14 @@ def _(item: uproot.reading.ReadOnlyDirectory) -> Literal[True]: # noqa: ARG001
53
57
54
58
55
59
@is_dir .register
56
- def _ (item : uproot .behaviors .TBranch .HasBranches ) -> bool :
57
- return len (item .branches ) > 0
58
-
59
-
60
- @is_dir .register
61
- def _ (item : uproot .behaviors .RNTuple .HasFields ) -> bool :
62
- return len (item .keys ()) > 0
60
+ def _ (
61
+ item : uproot .behaviors .TBranch .HasBranches | uproot .behaviors .RNTuple .HasFields ,
62
+ ) -> bool :
63
+ return len (item ) > 0
63
64
64
65
65
- def get_children (item : Mapping [str , Any ]) -> set [str ]:
66
- return {
67
- key .split (";" )[0 ]
68
- for key in item .keys () # noqa: SIM118
69
- if "/" not in key
70
- }
66
+ def get_children (item : SupportsRecursiveKeys ) -> set [str ]:
67
+ return {key .split (";" )[0 ] for key in item .keys (recursive = False )}
71
68
72
69
73
70
@dataclasses .dataclass
You can’t perform that action at this time.
0 commit comments