44import sys
55
66from enum import Enum
7- from typing import Literal , Union , cast
7+ from typing import ( # noqa: F401
8+ Literal ,
9+ TypeAlias ,
10+ TypeGuard ,
11+ Union ,
12+ cast ,
13+ )
814
915import numpy as np
1016
@@ -686,8 +692,10 @@ def _val_isinstance_of_union(val, union_type) -> builtins.bool:
686692bitType = uint64
687693
688694# Union aliases used for static and runtime type checking
689- bool_scalars = Union [builtins .bool , np .bool_ ]
690- float_scalars = Union [float , np .float64 , np .float32 ]
695+ bool_scalars = Union [builtins .bool , np .bool_ ] # type: TypeAlias
696+
697+ float_scalars = Union [float , np .float64 , np .float32 ] # type: TypeAlias
698+
691699int_scalars = Union [
692700 int ,
693701 np .int8 ,
@@ -698,9 +706,12 @@ def _val_isinstance_of_union(val, union_type) -> builtins.bool:
698706 np .uint16 ,
699707 np .uint32 ,
700708 np .uint64 ,
701- ]
702- numeric_scalars = Union [float_scalars , int_scalars ]
703- numeric_and_bool_scalars = Union [bool_scalars , numeric_scalars ]
709+ ] # type: TypeAlias
710+
711+ numeric_scalars = Union [float_scalars , int_scalars ] # type: TypeAlias
712+
713+ numeric_and_bool_scalars = Union [bool_scalars , numeric_scalars ] # type: TypeAlias
714+
704715numpy_scalars = Union [
705716 np .float64 ,
706717 np .float32 ,
@@ -714,9 +725,11 @@ def _val_isinstance_of_union(val, union_type) -> builtins.bool:
714725 np .uint16 ,
715726 np .uint32 ,
716727 np .uint64 ,
717- ]
718- str_scalars = Union [str , np .str_ ]
719- all_scalars = Union [bool_scalars , numeric_scalars , numpy_scalars , str_scalars ]
728+ ] # type: TypeAlias
729+
730+ str_scalars = Union [str , np .str_ ] # type: TypeAlias
731+
732+ all_scalars = Union [bool_scalars , numeric_scalars , numpy_scalars , str_scalars ] # type: TypeAlias
720733
721734"""
722735The DType enum defines the supported Arkouda data types in string form.
@@ -827,7 +840,7 @@ def __repr__(self) -> str:
827840ScalarDTypes = frozenset (["bool_" , "float64" , "int64" ])
828841
829842
830- def isSupportedInt (num ):
843+ def isSupportedInt (num ) -> "TypeGuard[int_scalars]" :
831844 """
832845 Whether a scalar is an arkouda supported integer dtype.
833846
@@ -853,7 +866,7 @@ def isSupportedInt(num):
853866 return isinstance (num , ARKOUDA_SUPPORTED_INTS )
854867
855868
856- def isSupportedFloat (num ):
869+ def isSupportedFloat (num ) -> "TypeGuard[float_scalars]" :
857870 """
858871 Whether a scalar is an arkouda supported float dtype.
859872
@@ -879,7 +892,7 @@ def isSupportedFloat(num):
879892 return isinstance (num , ARKOUDA_SUPPORTED_FLOATS )
880893
881894
882- def isSupportedNumber (num ):
895+ def isSupportedNumber (num ) -> "TypeGuard[numeric_scalars]" :
883896 """
884897 Whether a scalar is an arkouda supported numeric dtype.
885898
@@ -905,7 +918,7 @@ def isSupportedNumber(num):
905918 return isinstance (num , ARKOUDA_SUPPORTED_NUMBERS )
906919
907920
908- def isSupportedBool (num ):
921+ def isSupportedBool (num ) -> "TypeGuard[bool_scalars]" :
909922 """
910923 Whether a scalar is an arkouda supported boolean dtype.
911924
0 commit comments