11from __future__ import annotations
22
33import itertools
4- import sys
54from collections import defaultdict
6- from collections .abc import Iterable , Sequence
5+ from collections .abc import Callable , Iterable , Sequence
76from contextlib import suppress
87from functools import partial
98from operator import itemgetter
10- from typing import Any , Callable , Union , cast
9+ from typing import Any , Literal , TypeAlias , cast
1110
1211import numpy as np
1312
1615from adaptive .types import Int , Real
1716from adaptive .utils import cache_latest , named_product , restore
1817
19- if sys .version_info >= (3 , 10 ):
20- from typing import TypeAlias
21- else :
22- from typing_extensions import TypeAlias
23-
24- from typing import Literal
25-
2618try :
2719 import pandas
2820
@@ -38,11 +30,9 @@ def dispatch(child_functions: list[Callable], arg: Any) -> Any:
3830
3931STRATEGY_TYPE : TypeAlias = Literal ["loss_improvements" , "loss" , "npoints" , "cycle" ]
4032
41- CDIMS_TYPE : TypeAlias = Union [
42- Sequence [dict [str , Any ]],
43- tuple [Sequence [str ], Sequence [tuple [Any , ...]]],
44- None ,
45- ]
33+ CDIMS_TYPE : TypeAlias = (
34+ Sequence [dict [str , Any ]] | tuple [Sequence [str ], Sequence [tuple [Any , ...]]] | None
35+ )
4636
4737
4838class BalancingLearner (BaseLearner ):
0 commit comments