1515from  typing  import  (
1616    TYPE_CHECKING ,
1717    Any ,
18-     Dict ,
19-     List ,
20-     Optional ,
2118    Sequence ,
22-     Set ,
2319    Sized ,
24-     Tuple ,
25-     Type ,
26-     Union ,
2720    cast ,
2821    overload ,
2922)
125118
126119
127120def  maybe_convert_platform (
128-     values : Union [ list ,  tuple ,  range ,  np .ndarray ,  ExtensionArray ] 
121+     values : list   |   tuple   |   range   |   np .ndarray   |   ExtensionArray , 
129122) ->  ArrayLike :
130123    """ try to do platform conversion, allow ndarray or list here """ 
131124    if  isinstance (values , (list , tuple , range )):
@@ -159,7 +152,7 @@ def is_nested_object(obj) -> bool:
159152    )
160153
161154
162- def  maybe_box_datetimelike (value : Scalar , dtype : Optional [ Dtype ]  =  None ) ->  Scalar :
155+ def  maybe_box_datetimelike (value : Scalar , dtype : Dtype   |   None  =  None ) ->  Scalar :
163156    """ 
164157    Cast scalar to Timestamp or Timedelta if scalar is datetime-like 
165158    and dtype is not object. 
@@ -245,9 +238,7 @@ def _disallow_mismatched_datetimelike(value, dtype: DtypeObj):
245238        raise  TypeError (f"Cannot cast { repr (value )}   to { dtype }  " )
246239
247240
248- def  maybe_downcast_to_dtype (
249-     result : ArrayLike , dtype : Union [str , np .dtype ]
250- ) ->  ArrayLike :
241+ def  maybe_downcast_to_dtype (result : ArrayLike , dtype : str  |  np .dtype ) ->  ArrayLike :
251242    """ 
252243    try to cast to the specified dtype (e.g. convert back to bool/int 
253244    or could be an astype of float64->float32 
@@ -460,7 +451,7 @@ def maybe_cast_result_dtype(dtype: DtypeObj, how: str) -> DtypeObj:
460451
461452
462453def  maybe_cast_to_extension_array (
463-     cls : Type [ExtensionArray ], obj : ArrayLike , dtype : Optional [ ExtensionDtype ]  =  None 
454+     cls : type [ExtensionArray ], obj : ArrayLike , dtype : ExtensionDtype   |   None  =  None 
464455) ->  ArrayLike :
465456    """ 
466457    Call to `_from_sequence` that returns the object unchanged on Exception. 
@@ -727,7 +718,7 @@ def _ensure_dtype_type(value, dtype: np.dtype):
727718    return  dtype .type (value )
728719
729720
730- def  infer_dtype_from (val , pandas_dtype : bool  =  False ) ->  Tuple [DtypeObj , Any ]:
721+ def  infer_dtype_from (val , pandas_dtype : bool  =  False ) ->  tuple [DtypeObj , Any ]:
731722    """ 
732723    Interpret the dtype from a scalar or array. 
733724
@@ -744,7 +735,7 @@ def infer_dtype_from(val, pandas_dtype: bool = False) -> Tuple[DtypeObj, Any]:
744735    return  infer_dtype_from_array (val , pandas_dtype = pandas_dtype )
745736
746737
747- def  infer_dtype_from_scalar (val , pandas_dtype : bool  =  False ) ->  Tuple [DtypeObj , Any ]:
738+ def  infer_dtype_from_scalar (val , pandas_dtype : bool  =  False ) ->  tuple [DtypeObj , Any ]:
748739    """ 
749740    Interpret the dtype from a scalar. 
750741
@@ -834,7 +825,7 @@ def infer_dtype_from_scalar(val, pandas_dtype: bool = False) -> Tuple[DtypeObj,
834825    return  dtype , val 
835826
836827
837- def  dict_compat (d : Dict [Scalar , Scalar ]) ->  Dict [Scalar , Scalar ]:
828+ def  dict_compat (d : dict [Scalar , Scalar ]) ->  dict [Scalar , Scalar ]:
838829    """ 
839830    Convert datetimelike-keyed dicts to a Timestamp-keyed dict. 
840831
@@ -852,7 +843,7 @@ def dict_compat(d: Dict[Scalar, Scalar]) -> Dict[Scalar, Scalar]:
852843
853844def  infer_dtype_from_array (
854845    arr , pandas_dtype : bool  =  False 
855- ) ->  Tuple [DtypeObj , ArrayLike ]:
846+ ) ->  tuple [DtypeObj , ArrayLike ]:
856847    """ 
857848    Infer the dtype from an array. 
858849
@@ -944,7 +935,7 @@ def maybe_upcast(
944935    values : np .ndarray ,
945936    fill_value : Scalar  =  np .nan ,
946937    copy : bool  =  False ,
947- ) ->  Tuple [np .ndarray , Scalar ]:
938+ ) ->  tuple [np .ndarray , Scalar ]:
948939    """ 
949940    Provide explicit type promotion and coercion. 
950941
@@ -970,7 +961,7 @@ def maybe_upcast(
970961    return  values , fill_value 
971962
972963
973- def  invalidate_string_dtypes (dtype_set : Set [DtypeObj ]):
964+ def  invalidate_string_dtypes (dtype_set : set [DtypeObj ]):
974965    """ 
975966    Change string like dtypes to object for 
976967    ``DataFrame.select_dtypes()``. 
@@ -1524,7 +1515,7 @@ def maybe_castable(dtype: np.dtype) -> bool:
15241515    return  dtype .name  not  in   POSSIBLY_CAST_DTYPES 
15251516
15261517
1527- def  maybe_infer_to_datetimelike (value : Union [ np .ndarray ,  List ] ):
1518+ def  maybe_infer_to_datetimelike (value : np .ndarray   |   list ):
15281519    """ 
15291520    we might have a array (or single object) that is datetime like, 
15301521    and no dtype is passed don't change the value unless we find a 
@@ -1619,8 +1610,8 @@ def try_timedelta(v: np.ndarray) -> np.ndarray:
16191610
16201611
16211612def  maybe_cast_to_datetime (
1622-     value : Union [ ExtensionArray ,  np .ndarray ,  list ] , dtype : Optional [ DtypeObj ] 
1623- ) ->  Union [ ExtensionArray ,  np .ndarray ,  list ] :
1613+     value : ExtensionArray   |   np .ndarray   |   list , dtype : DtypeObj   |   None 
1614+ ) ->  ExtensionArray   |   np .ndarray   |   list :
16241615    """ 
16251616    try to cast the array/value to a datetimelike dtype, converting float 
16261617    nan to iNaT 
@@ -1784,7 +1775,7 @@ def ensure_nanosecond_dtype(dtype: DtypeObj) -> DtypeObj:
17841775    return  dtype 
17851776
17861777
1787- def  find_common_type (types : List [DtypeObj ]) ->  DtypeObj :
1778+ def  find_common_type (types : list [DtypeObj ]) ->  DtypeObj :
17881779    """ 
17891780    Find a common data type among the given dtypes. 
17901781
@@ -1873,7 +1864,7 @@ def construct_2d_arraylike_from_scalar(
18731864
18741865
18751866def  construct_1d_arraylike_from_scalar (
1876-     value : Scalar , length : int , dtype : Optional [ DtypeObj ] 
1867+     value : Scalar , length : int , dtype : DtypeObj   |   None 
18771868) ->  ArrayLike :
18781869    """ 
18791870    create a np.ndarray / pandas type of specified shape and dtype 
@@ -1947,7 +1938,7 @@ def construct_1d_object_array_from_listlike(values: Sized) -> np.ndarray:
19471938
19481939
19491940def  construct_1d_ndarray_preserving_na (
1950-     values : Sequence , dtype : Optional [ DtypeObj ]  =  None , copy : bool  =  False 
1941+     values : Sequence , dtype : DtypeObj   |   None  =  None , copy : bool  =  False 
19511942) ->  np .ndarray :
19521943    """ 
19531944    Construct a new ndarray, coercing `values` to `dtype`, preserving NA. 
@@ -1997,7 +1988,7 @@ def construct_1d_ndarray_preserving_na(
19971988
19981989
19991990def  maybe_cast_to_integer_array (
2000-     arr : Union [ list ,  np .ndarray ] , dtype : np .dtype , copy : bool  =  False 
1991+     arr : list   |   np .ndarray , dtype : np .dtype , copy : bool  =  False 
20011992):
20021993    """ 
20031994    Takes any dtype and returns the casted version, raising for when data is 
0 commit comments