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 (
1226 PandasBooleanDtypeArg ,
13- PandasFloatDtypeArg ,
14- PandasIntDtypeArg ,
15- PandasUIntDtypeArg ,
27+ np_ndarray ,
1628 np_ndarray_anyint ,
1729 np_ndarray_bool ,
30+ np_ndarray_dt ,
1831 np_ndarray_float ,
32+ np_ndarray_td ,
1933)
2034
2135from pandas .core .dtypes .dtypes import ExtensionDtype
@@ -27,22 +41,75 @@ def array( # type: ignore[overload-overlap] # pyright: ignore[reportOverlapping
2741 copy : bool = True ,
2842) -> BooleanArray : ...
2943@overload
44+ def array ( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
45+ data : Sequence [NAType | None ],
46+ dtype : str | np .dtype | ExtensionDtype | None = None ,
47+ copy : bool = True ,
48+ ) -> NumpyExtensionArray : ...
49+ @overload
3050def array ( # type: ignore[overload-overlap]
31- data : Sequence [int | np .integer | NAType | None ] | np_ndarray_anyint | IntegerArray ,
32- dtype : PandasIntDtypeArg | PandasUIntDtypeArg | None = None ,
51+ data : (
52+ Sequence [bool | np .bool | NAType | None ]
53+ | np_ndarray_bool
54+ | BooleanArray
55+ | Index [bool ]
56+ | Series [int ]
57+ ),
58+ dtype : str | np .dtype | ExtensionDtype | None = None ,
59+ copy : bool = True ,
60+ ) -> BooleanArray : ...
61+ @overload
62+ def array ( # type: ignore[overload-overlap]
63+ data : (
64+ Sequence [int | np .integer | NAType | None ]
65+ | np_ndarray_anyint
66+ | IntegerArray
67+ | Index [int ]
68+ | RangeIndex
69+ | Series [int ]
70+ ),
71+ dtype : str | np .dtype | ExtensionDtype | None = None ,
3372 copy : bool = True ,
3473) -> IntegerArray : ...
3574@overload
36- def array (
75+ def array ( # type: ignore[overload-overlap]
3776 data : (
38- Sequence [float | np .floating | NAType | None ] | np_ndarray_float | FloatingArray
77+ Sequence [float | np .floating | NAType | None ]
78+ | np_ndarray_float
79+ | FloatingArray
80+ | Index [float ]
81+ | Series [float ]
3982 ),
40- dtype : PandasFloatDtypeArg | None = None ,
83+ dtype : str | np . dtype | ExtensionDtype | None = None ,
4184 copy : bool = True ,
4285) -> FloatingArray : ...
4386@overload
87+ def array ( # type: ignore[overload-overlap]
88+ data : (
89+ Sequence [Timestamp | np .datetime64 | NaTType | None ]
90+ | np_ndarray_dt
91+ | DatetimeArray
92+ | DatetimeIndex
93+ | Series [Timestamp ]
94+ ),
95+ dtype : str | np .dtype | ExtensionDtype | None = None ,
96+ copy : bool = True ,
97+ ) -> DatetimeArray : ...
98+ @overload
99+ def array ( # type: ignore[overload-overlap]
100+ data : (
101+ Sequence [Timedelta | np .timedelta64 | NaTType | None ]
102+ | np_ndarray_td
103+ | TimedeltaArray
104+ | TimedeltaIndex
105+ | Series [Timedelta ]
106+ ),
107+ dtype : str | np .dtype | ExtensionDtype | None = None ,
108+ copy : bool = True ,
109+ ) -> TimedeltaArray : ...
110+ @overload
44111def array (
45- data : Sequence [object ] ,
112+ data : Sequence [Any ] | np_ndarray | ExtensionArray | Index | Series ,
46113 dtype : str | np .dtype | ExtensionDtype | None = None ,
47114 copy : bool = True ,
48- ) -> ExtensionArray : ...
115+ ) -> NumpyExtensionArray : ...
0 commit comments