|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | import abc |
| 16 | +import collections |
16 | 17 | import logging |
17 | 18 | import time |
18 | 19 | from collections import defaultdict |
@@ -173,7 +174,7 @@ def get_cost_value( |
173 | 174 | costs_cache = {} |
174 | 175 | if generalizer is None: |
175 | 176 | generalizer = lambda b: b |
176 | | - if isinstance(generalizer, (list, tuple)): |
| 177 | + if isinstance(generalizer, collections.abc.Sequence): |
177 | 178 | generalizer = _make_composite_generalizer(*generalizer) |
178 | 179 |
|
179 | 180 | cost_val = _get_cost_value(bloq, cost_key, costs_cache=costs_cache, generalizer=generalizer) |
@@ -210,7 +211,7 @@ def get_cost_cache( |
210 | 211 | costs_cache = {} |
211 | 212 | if generalizer is None: |
212 | 213 | generalizer = lambda b: b |
213 | | - if isinstance(generalizer, (list, tuple)): |
| 214 | + if isinstance(generalizer, collections.abc.Sequence): |
214 | 215 | generalizer = _make_composite_generalizer(*generalizer) |
215 | 216 |
|
216 | 217 | _get_cost_value(bloq, cost_key, costs_cache=costs_cache, generalizer=generalizer) |
@@ -240,7 +241,7 @@ def query_costs( |
240 | 241 | A dictionary of dictionaries forming a table of multiple costs for multiple bloqs. |
241 | 242 | This is indexed by bloq, then cost key. |
242 | 243 | """ |
243 | | - costs = defaultdict(dict) |
| 244 | + costs: Dict['Bloq', Dict[CostKey, CostValT]] = defaultdict(dict) |
244 | 245 | for cost_key in cost_keys: |
245 | 246 | cost_for_bloqs = get_cost_cache(bloq, cost_key, generalizer=generalizer) |
246 | 247 | for bloq, val in cost_for_bloqs.items(): |
|
0 commit comments