23
23
}
24
24
25
25
26
- def _calculate_contributes (values : Sequence [str | GroupingComponent ]) -> bool :
26
+ def _calculate_contributes (values : Sequence [str | int | GroupingComponent ]) -> bool :
27
27
for value in values or ():
28
28
if not isinstance (value , GroupingComponent ) or value .contributes :
29
29
return True
@@ -38,14 +38,14 @@ class GroupingComponent:
38
38
id : str = "default"
39
39
hint : str | None
40
40
contributes : bool
41
- values : Sequence [str | GroupingComponent ]
41
+ values : Sequence [str | int | GroupingComponent ]
42
42
43
43
def __init__ (
44
44
self ,
45
45
id : str | None = None ,
46
46
hint : str | None = None ,
47
47
contributes : bool | None = None ,
48
- values : Sequence [str | GroupingComponent ] | None = None ,
48
+ values : Sequence [str | int | GroupingComponent ] | None = None ,
49
49
variant_provider : bool = False ,
50
50
):
51
51
self .id = id or self .id
@@ -54,7 +54,7 @@ def __init__(
54
54
self .hint = DEFAULT_HINTS .get (self .id )
55
55
self .contributes = contributes
56
56
self .variant_provider = variant_provider
57
- self .values : Sequence [str | GroupingComponent ] = []
57
+ self .values : Sequence [str | int | GroupingComponent ] = []
58
58
59
59
self .update (
60
60
hint = hint ,
@@ -89,13 +89,13 @@ def _walk_components(c: GroupingComponent, stack: list[str | None]) -> None:
89
89
90
90
def get_subcomponent (
91
91
self , id : str , only_contributing : bool = False
92
- ) -> str | GroupingComponent | None :
92
+ ) -> str | int | GroupingComponent | None :
93
93
"""Looks up a subcomponent by the id and returns the first or `None`."""
94
94
return next (self .iter_subcomponents (id = id , only_contributing = only_contributing ), None )
95
95
96
96
def iter_subcomponents (
97
97
self , id : str , recursive : bool = False , only_contributing : bool = False
98
- ) -> Iterator [str | GroupingComponent | None ]:
98
+ ) -> Iterator [str | int | GroupingComponent | None ]:
99
99
"""Finds all subcomponents matching an id, optionally recursively."""
100
100
for value in self .values :
101
101
if isinstance (value , GroupingComponent ):
@@ -113,7 +113,7 @@ def update(
113
113
self ,
114
114
hint : str | None = None ,
115
115
contributes : bool | None = None ,
116
- values : Sequence [str | GroupingComponent ] | None = None ,
116
+ values : Sequence [str | int | GroupingComponent ] | None = None ,
117
117
) -> None :
118
118
"""Updates an already existing component with new values."""
119
119
if hint is not None :
@@ -132,7 +132,7 @@ def shallow_copy(self) -> GroupingComponent:
132
132
rv .values = list (self .values )
133
133
return rv
134
134
135
- def iter_values (self ) -> Generator [str | GroupingComponent ]:
135
+ def iter_values (self ) -> Generator [str | int | GroupingComponent ]:
136
136
"""Recursively walks the component and flattens it into a list of
137
137
values.
138
138
"""
0 commit comments