@@ -21,6 +21,7 @@ from pandas.core.arrays.numpy_ import NumpyExtensionArray
2121from pandas .core .arrays .period import PeriodArray
2222from pandas .core .arrays .sparse .array import SparseArray
2323from pandas .core .arrays .string_ import StringArray
24+ from pandas .core .arrays .string_arrow import ArrowStringArray
2425from pandas .core .arrays .timedeltas import TimedeltaArray
2526from pandas .core .indexes .base import Index
2627from pandas .core .indexes .category import CategoricalIndex
@@ -39,16 +40,22 @@ from pandas._libs.tslibs.period import Period
3940from pandas ._libs .tslibs .timedeltas import Timedelta
4041from pandas ._libs .tslibs .timestamps import Timestamp
4142from pandas ._typing import (
42- BooleanDtypeArg ,
43+ BuiltinBooleanDtypeArg ,
44+ BuiltinFloatDtypeArg ,
45+ BuiltinIntDtypeArg ,
46+ BuiltinStrDtypeArg ,
4347 CategoryDtypeArg ,
44- FloatDtypeArg ,
45- IntDtypeArg ,
4648 IntervalT ,
49+ NumpyDtypeArg ,
50+ PandasBooleanDtypeArg ,
51+ PandasFloatDtypeArg ,
52+ PandasIntDtypeArg ,
53+ PandasStrDtypeArg ,
54+ PandasTimestampDtypeArg ,
55+ PandasUIntDtypeArg ,
56+ PyArrowNotStrDtypeArg ,
57+ PyArrowStrDtypeArg ,
4758 SequenceNotStr ,
48- StrDtypeArg ,
49- TimedeltaDtypeArg ,
50- TimestampDtypeArg ,
51- UIntDtypeArg ,
5259 np_ndarray ,
5360 np_ndarray_anyint ,
5461 np_ndarray_bool ,
@@ -64,18 +71,46 @@ from pandas.core.dtypes.dtypes import (
6471 PeriodDtype ,
6572)
6673
74+ # @overload
75+ # def array(
76+ # data: SequenceNotStr[NAType | None],
77+ # dtype: None = None,
78+ # copy: bool = True
79+ # ) -> NumpyExtensionArray: ...
6780@overload
68- def array ( # type: ignore[overload-overlap]
81+ def array ( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
6982 data : SequenceNotStr [Any ] | np_ndarray | ExtensionArray | Index | Series ,
7083 dtype : CategoryDtypeArg ,
7184 copy : bool = True ,
7285) -> Categorical : ...
7386@overload
87+ def array (
88+ # TODO: Categorical Series pandas-dev/pandas-stubs#1415
89+ data : Categorical | CategoricalIndex ,
90+ dtype : CategoryDtypeArg | None = None ,
91+ copy : bool = True ,
92+ ) -> Categorical : ...
93+ @overload
7494def array ( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
75- data : Sequence [NAType | None ],
95+ data : (
96+ Sequence [Period | NaTType | None ] | PeriodArray | PeriodIndex | Series [Period ]
97+ ),
98+ dtype : PeriodDtype | None = None ,
99+ copy : bool = True ,
100+ ) -> PeriodArray : ...
101+ @overload
102+ def array ( # type: ignore[overload-overlap]
103+ # float("nan") also works, but I don't know how to put it in
104+ data : Sequence [IntervalT | None ] | IntervalArray | IntervalIndex | Series [Interval ],
105+ dtype : IntervalDtype | None = None ,
106+ copy : bool = True ,
107+ ) -> IntervalArray : ...
108+ @overload
109+ def array (
110+ data : SparseArray | SparseIndex ,
76111 dtype : str | np .dtype | ExtensionDtype | None = None ,
77112 copy : bool = True ,
78- ) -> NumpyExtensionArray : ...
113+ ) -> SparseArray : ...
79114@overload
80115def array ( # type: ignore[overload-overlap]
81116 data : (
@@ -85,21 +120,21 @@ def array( # type: ignore[overload-overlap]
85120 | Index [bool ]
86121 | Series [int ]
87122 ),
88- dtype : BooleanDtypeArg | None = None ,
123+ dtype : BuiltinBooleanDtypeArg | PandasBooleanDtypeArg | None = None ,
89124 copy : bool = True ,
90125) -> BooleanArray : ...
91126@overload
92127def array ( # type: ignore[overload-overlap]
93128 data : Sequence [int | np .integer | NAType | None ] | np_ndarray_anyint | IntegerArray ,
94- dtype : IntDtypeArg | UIntDtypeArg | None = None ,
129+ dtype : BuiltinIntDtypeArg | PandasIntDtypeArg | PandasUIntDtypeArg | None = None ,
95130 copy : bool = True ,
96131) -> IntegerArray : ...
97132@overload
98133def array ( # type: ignore[overload-overlap]
99134 data : (
100135 Sequence [float | np .floating | NAType | None ] | np_ndarray_float | FloatingArray
101136 ),
102- dtype : FloatDtypeArg | None = None ,
137+ dtype : BuiltinFloatDtypeArg | PandasFloatDtypeArg | None = None ,
103138 copy : bool = True ,
104139) -> FloatingArray : ...
105140@overload
@@ -112,75 +147,54 @@ def array( # type: ignore[overload-overlap]
112147 | DatetimeIndex
113148 | Series [Timestamp ]
114149 ),
115- dtype : TimestampDtypeArg | None = None ,
150+ dtype : PandasTimestampDtypeArg | None = None ,
116151 copy : bool = True ,
117152) -> DatetimeArray : ...
118153@overload
119- def array ( # type: ignore[overload-overlap]
154+ def array (
120155 data : (
121156 Sequence [timedelta | np .timedelta64 | NaTType | None ]
122157 | np_ndarray_td
123158 | TimedeltaArray
124159 | TimedeltaIndex
125160 | Series [Timedelta ]
126161 ),
127- dtype : TimedeltaDtypeArg | None = None ,
162+ dtype : None = None ,
128163 copy : bool = True ,
129164) -> TimedeltaArray : ...
130165@overload
131- def array (
166+ def array ( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
132167 data : SequenceNotStr [str | np .str_ | NAType | None ] | np_ndarray_str | StringArray ,
133- dtype : StrDtypeArg | None = None ,
168+ dtype : BuiltinStrDtypeArg | PandasStrDtypeArg | None = None ,
134169 copy : bool = True ,
135170) -> StringArray : ...
136171@overload
137172def array ( # type: ignore[overload-overlap]
138173 data : (
139- Sequence [Period | NaTType | None ] | PeriodArray | PeriodIndex | Series [Period ]
174+ SequenceNotStr [str | np .str_ | NAType | None ]
175+ | np_ndarray_str
176+ | StringArray
177+ | ArrowStringArray
140178 ),
141- dtype : PeriodDtype | None = None ,
142- copy : bool = True ,
143- ) -> PeriodArray : ...
144- @overload
145- def array (
146- # float("nan") also works, but I don't know how to put it in
147- data : Sequence [IntervalT | None ] | IntervalArray | IntervalIndex | Series [Interval ],
148- dtype : IntervalDtype | None = None ,
179+ dtype : PyArrowStrDtypeArg | None = None ,
149180 copy : bool = True ,
150- ) -> IntervalArray : ...
151- @overload
152- def array (
153- # TODO: Categorical Series pandas-dev/pandas-stubs#1415
154- data : Categorical | CategoricalIndex ,
155- dtype : CategoryDtypeArg | None = None ,
156- copy : bool = True ,
157- ) -> Categorical : ...
181+ ) -> ArrowStringArray : ...
158182@overload
159183def array (
160- data : (
161- SequenceNotStr [object ]
162- | np .typing .NDArray [np .object_ ]
163- | NumpyExtensionArray
164- | RangeIndex
165- ),
166- dtype : str | np .dtype | ExtensionDtype | None = None ,
184+ data : SequenceNotStr [object ] | np_ndarray | NumpyExtensionArray | RangeIndex ,
185+ dtype : NumpyDtypeArg | None = None ,
167186 copy : bool = True ,
168187) -> NumpyExtensionArray : ...
169188@overload
170- def array (
171- data : SparseArray | SparseIndex ,
172- dtype : str | np .dtype | ExtensionDtype | None = None ,
173- copy : bool = True ,
174- ) -> SparseArray : ...
175- @overload
176189def array (
177190 data : ArrowExtensionArray ,
178- dtype : str | np . dtype | ExtensionDtype | None = None ,
191+ dtype : PyArrowNotStrDtypeArg | None = None ,
179192 copy : bool = True ,
180193) -> ArrowExtensionArray : ...
181- @overload
182- def array (
183- data : SequenceNotStr [Any ] | np_ndarray | ExtensionArray | Index | Series ,
184- dtype : str | np .dtype | ExtensionDtype | None = None ,
185- copy : bool = True ,
186- ) -> ExtensionArray : ...
194+
195+ # @overload
196+ # def array(
197+ # data: SequenceNotStr[Any] | np_ndarray | ExtensionArray | Index | Series,
198+ # dtype: str | np.dtype | ExtensionDtype | None = None,
199+ # copy: bool = True,
200+ # ) -> ExtensionArray: ...
0 commit comments