@@ -6,38 +6,59 @@ from typing import (
66)
77
88import numpy as np
9+ from pandas .core .arrays .arrow .array import ArrowExtensionArray
910from pandas .core .arrays .base import ExtensionArray
1011from pandas .core .arrays .boolean import BooleanArray
12+ from pandas .core .arrays .categorical import Categorical
1113from pandas .core .arrays .datetimes import DatetimeArray
1214from pandas .core .arrays .floating import FloatingArray
1315from pandas .core .arrays .integer import IntegerArray
16+ from pandas .core .arrays .interval import IntervalArray
1417from pandas .core .arrays .numpy_ import NumpyExtensionArray
18+ from pandas .core .arrays .period import PeriodArray
19+ from pandas .core .arrays .sparse .array import SparseArray
20+ from pandas .core .arrays .string_ import StringArray
1521from pandas .core .arrays .timedeltas import TimedeltaArray
1622from pandas .core .indexes .base import Index
23+ from pandas .core .indexes .category import CategoricalIndex
1724from pandas .core .indexes .datetimes import DatetimeIndex
25+ from pandas .core .indexes .interval import IntervalIndex
26+ from pandas .core .indexes .period import PeriodIndex
1827from pandas .core .indexes .range import RangeIndex
1928from pandas .core .indexes .timedeltas import TimedeltaIndex
2029from pandas .core .series import Series
2130
31+ from pandas ._libs .interval import Interval
2232from pandas ._libs .missing import NAType
33+ from pandas ._libs .sparse import SparseIndex
2334from pandas ._libs .tslibs .nattype import NaTType
35+ from pandas ._libs .tslibs .period import Period
2436from pandas ._libs .tslibs .timedeltas import Timedelta
2537from pandas ._libs .tslibs .timestamps import Timestamp
2638from pandas ._typing import (
2739 BooleanDtypeArg ,
40+ CategoryDtypeArg ,
2841 FloatDtypeArg ,
2942 IntDtypeArg ,
43+ IntervalT ,
44+ SequenceNotStr ,
45+ StrDtypeArg ,
3046 TimedeltaDtypeArg ,
3147 TimestampDtypeArg ,
3248 np_ndarray ,
3349 np_ndarray_anyint ,
3450 np_ndarray_bool ,
3551 np_ndarray_dt ,
3652 np_ndarray_float ,
53+ np_ndarray_str ,
3754 np_ndarray_td ,
3855)
3956
40- from pandas .core .dtypes .dtypes import ExtensionDtype
57+ from pandas .core .dtypes .dtypes import (
58+ ExtensionDtype ,
59+ IntervalDtype ,
60+ PeriodDtype ,
61+ )
4162
4263@overload
4364def array ( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
@@ -96,12 +117,53 @@ def array( # type: ignore[overload-overlap]
96117 copy : bool = True ,
97118) -> TimedeltaArray : ...
98119@overload
120+ def array (
121+ data : SequenceNotStr [str | np .str_ | NAType | None ] | np_ndarray_str | StringArray ,
122+ dtype : StrDtypeArg | None = None ,
123+ copy : bool = True ,
124+ ) -> StringArray : ...
125+ @overload
126+ def array ( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
127+ data : Sequence [Period | NAType | None ] | PeriodArray | PeriodIndex | Series [Period ],
128+ dtype : PeriodDtype | None = None ,
129+ copy : bool = True ,
130+ ) -> PeriodIndex : ...
131+ @overload
132+ def array ( # type: ignore[overload-overlap]
133+ data : (
134+ Sequence [IntervalT | NAType | None ]
135+ | IntervalIndex
136+ | Series [Interval ]
137+ | IntervalArray
138+ ),
139+ dtype : IntervalDtype | None = None ,
140+ copy : bool = True ,
141+ ) -> IntervalArray : ...
142+ @overload
143+ def array (
144+ data : Categorical | CategoricalIndex ,
145+ dtype : CategoryDtypeArg | None = None ,
146+ copy : bool = True ,
147+ ) -> Categorical : ...
148+ @overload
99149def array (
100150 data : Sequence [object ] | np .typing .NDArray [np .object_ ] | RangeIndex ,
101151 dtype : str | np .dtype | ExtensionDtype | None = None ,
102152 copy : bool = True ,
103153) -> NumpyExtensionArray : ...
104154@overload
155+ def array ( # type: ignore[overload-overlap]
156+ data : SparseArray | SparseIndex ,
157+ dtype : str | np .dtype | ExtensionDtype | None = None ,
158+ copy : bool = True ,
159+ ) -> SparseIndex : ...
160+ @overload
161+ def array (
162+ data : ArrowExtensionArray ,
163+ dtype : str | np .dtype | ExtensionDtype | None = None ,
164+ copy : bool = True ,
165+ ) -> ArrowExtensionArray : ...
166+ @overload
105167def array (
106168 data : Sequence [Any ] | np_ndarray | ExtensionArray | Index [Any ] | Series [Any ],
107169 dtype : str | np .dtype | ExtensionDtype | None = None ,
0 commit comments