2626
2727if typing .TYPE_CHECKING :
2828 from os import PathLike
29- from typing import (
30- Any ,
31- Callable ,
32- Iterable ,
33- Iterator ,
34- Sequence ,
35- Union ,
36- )
29+ from typing import Any , Callable , Iterable , Iterator , Sequence , TypeAlias
3730
3831 from numpy .typing import NDArray
3932 from pandas import DataFrame , Series
4033
4134 from .config import Core
4235
43- StepIndex = Union [ int , slice ]
36+ StepIndex : TypeAlias = int | slice
4437
4538
4639@typing .overload
@@ -56,8 +49,8 @@ def _as_view_item(obj: int) -> None: ...
5649
5750
5851def _as_view_item (
59- obj : Union [ Sequence [StepIndex ], slice , int ] ,
60- ) -> Union [ Sequence [StepIndex ], Sequence [slice ], None ] :
52+ obj : Sequence [StepIndex ] | slice | int ,
53+ ) -> Sequence [StepIndex ] | Sequence [slice ] | None :
6154 """Return None or a suitable iterable to build a StepsView."""
6255 try :
6356 iter (obj ) # type: ignore
@@ -312,11 +305,9 @@ def __repr__(self) -> str:
312305 def __getitem__ (self , istep : int ) -> Step : ...
313306
314307 @typing .overload
315- def __getitem__ (self , istep : Union [ slice , Sequence [StepIndex ] ]) -> StepsView : ...
308+ def __getitem__ (self , istep : slice | Sequence [StepIndex ]) -> StepsView : ...
316309
317- def __getitem__ (
318- self , istep : Union [int , slice , Sequence [StepIndex ]]
319- ) -> Union [Step , StepsView ]:
310+ def __getitem__ (self , istep : int | slice | Sequence [StepIndex ]) -> Step | StepsView :
320311 keys = _as_view_item (istep )
321312 if keys is not None :
322313 return StepsView (self , keys )
@@ -406,9 +397,9 @@ def __repr__(self) -> str:
406397 def __getitem__ (self , istep : int ) -> Step : ...
407398
408399 @typing .overload
409- def __getitem__ (self , istep : Union [ slice , Sequence [StepIndex ] ]) -> StepsView : ...
400+ def __getitem__ (self , istep : slice | Sequence [StepIndex ]) -> StepsView : ...
410401
411- def __getitem__ (self , isnap : Any ) -> Union [ Step , StepsView ] :
402+ def __getitem__ (self , isnap : Any ) -> Step | StepsView :
412403 keys = _as_view_item (isnap )
413404 if keys is not None :
414405 return StepsView (self , keys ).filter (snap = True )
@@ -545,7 +536,7 @@ class StepsView:
545536 items: iterable of isteps/isnaps or slices.
546537 """
547538
548- def __init__ (self , steps_col : Union [ Steps , Snaps ] , items : Sequence [StepIndex ]):
539+ def __init__ (self , steps_col : Steps | Snaps , items : Sequence [StepIndex ]):
549540 self ._col = steps_col
550541 self ._items = items
551542 self ._rprofs_averaged : RprofsAveraged | None = None
0 commit comments