11from collections .abc import Sequence
2- from typing import overload
2+ from typing import (
3+ Any ,
4+ overload ,
5+ )
36
47import numpy as np
58from pandas .core .arrays .base import ExtensionArray
69from pandas .core .arrays .boolean import BooleanArray
10+ from pandas .core .arrays .datetimes import DatetimeArray
711from pandas .core .arrays .floating import FloatingArray
812from pandas .core .arrays .integer import IntegerArray
13+ from pandas .core .arrays .numpy_ import NumpyExtensionArray
14+ from pandas .core .arrays .timedeltas import TimedeltaArray
15+ from pandas .core .indexes .base import Index
16+ from pandas .core .indexes .datetimes import DatetimeIndex
17+ from pandas .core .indexes .range import RangeIndex
18+ from pandas .core .indexes .timedeltas import TimedeltaIndex
19+ from pandas .core .series import Series
920
1021from pandas ._libs .missing import NAType
22+ from pandas ._libs .tslibs .nattype import NaTType
23+ from pandas ._libs .tslibs .timedeltas import Timedelta
24+ from pandas ._libs .tslibs .timestamps import Timestamp
1125from pandas ._typing import (
12- PandasBooleanDtypeArg ,
13- PandasFloatDtypeArg ,
14- PandasIntDtypeArg ,
15- PandasUIntDtypeArg ,
26+ np_ndarray ,
1627 np_ndarray_anyint ,
1728 np_ndarray_bool ,
29+ np_ndarray_dt ,
1830 np_ndarray_float ,
31+ np_ndarray_td ,
1932)
2033
2134from pandas .core .dtypes .dtypes import ExtensionDtype
@@ -27,22 +40,75 @@ def array( # type: ignore[overload-overlap] # pyright: ignore[reportOverlapping
2740 copy : bool = True ,
2841) -> BooleanArray : ...
2942@overload
43+ def array ( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
44+ data : Sequence [NAType | None ],
45+ dtype : str | np .dtype | ExtensionDtype | None = None ,
46+ copy : bool = True ,
47+ ) -> NumpyExtensionArray : ...
48+ @overload
49+ def array ( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
50+ data : (
51+ Sequence [bool | np .bool | NAType | None ]
52+ | np_ndarray_bool
53+ | BooleanArray
54+ | Index [bool ]
55+ | Series [int ]
56+ ),
57+ dtype : str | np .dtype | ExtensionDtype | None = None ,
58+ copy : bool = True ,
59+ ) -> BooleanArray : ...
60+ @overload
3061def array ( # type: ignore[overload-overlap]
31- data : Sequence [int | np .integer | NAType | None ] | np_ndarray_anyint | IntegerArray ,
32- dtype : PandasIntDtypeArg | PandasUIntDtypeArg | None = None ,
62+ data : (
63+ Sequence [int | np .integer | NAType | None ]
64+ | np_ndarray_anyint
65+ | IntegerArray
66+ | Index [int ]
67+ | RangeIndex
68+ | Series [int ]
69+ ),
70+ dtype : str | np .dtype | ExtensionDtype | None = None ,
3371 copy : bool = True ,
3472) -> IntegerArray : ...
3573@overload
36- def array (
74+ def array ( # type: ignore[overload-overlap]
3775 data : (
38- Sequence [float | np .floating | NAType | None ] | np_ndarray_float | FloatingArray
76+ Sequence [float | np .floating | NAType | None ]
77+ | np_ndarray_float
78+ | FloatingArray
79+ | Index [float ]
80+ | Series [float ]
3981 ),
40- dtype : PandasFloatDtypeArg | None = None ,
82+ dtype : str | np . dtype | ExtensionDtype | None = None ,
4183 copy : bool = True ,
4284) -> FloatingArray : ...
4385@overload
86+ def array ( # type: ignore[overload-overlap]
87+ data : (
88+ Sequence [Timestamp | np .datetime64 | NaTType | None ]
89+ | np_ndarray_dt
90+ | DatetimeArray
91+ | DatetimeIndex
92+ | Series [Timestamp ]
93+ ),
94+ dtype : str | np .dtype | ExtensionDtype | None = None ,
95+ copy : bool = True ,
96+ ) -> DatetimeArray : ...
97+ @overload
98+ def array ( # type: ignore[overload-overlap]
99+ data : (
100+ Sequence [Timedelta | np .timedelta64 | NaTType | None ]
101+ | np_ndarray_td
102+ | TimedeltaArray
103+ | TimedeltaIndex
104+ | Series [Timedelta ]
105+ ),
106+ dtype : str | np .dtype | ExtensionDtype | None = None ,
107+ copy : bool = True ,
108+ ) -> TimedeltaArray : ...
109+ @overload
44110def array (
45- data : Sequence [object ] ,
111+ data : Sequence [Any ] | np_ndarray | ExtensionArray | Index | Series ,
46112 dtype : str | np .dtype | ExtensionDtype | None = None ,
47113 copy : bool = True ,
48- ) -> ExtensionArray : ...
114+ ) -> NumpyExtensionArray : ...
0 commit comments