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
11+ from pandas .core .arrays .floating import FloatingArray
712from 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
820
921from 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
1025from pandas ._typing import (
1126 BooleanDtypeArg ,
12- IntDtypeArg ,
13- UIntDtypeArg ,
27+ np_ndarray ,
28+ np_ndarray_anyint ,
29+ np_ndarray_bool ,
30+ np_ndarray_dt ,
31+ np_ndarray_float ,
32+ np_ndarray_td ,
1433)
1534
1635from pandas .core .dtypes .dtypes import ExtensionDtype
@@ -22,14 +41,75 @@ def array( # type: ignore[overload-overlap] # pyright: ignore[reportOverlapping
2241 copy : bool = True ,
2342) -> BooleanArray : ...
2443@overload
25- def array (
26- data : Sequence [int | NAType | None ],
27- dtype : IntDtypeArg | UIntDtypeArg | None = None ,
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
50+ def array ( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
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 ,
2872 copy : bool = True ,
2973) -> IntegerArray : ...
3074@overload
75+ def array ( # type: ignore[overload-overlap]
76+ data : (
77+ Sequence [float | np .floating | NAType | None ]
78+ | np_ndarray_float
79+ | FloatingArray
80+ | Index [float ]
81+ | Series [float ]
82+ ),
83+ dtype : str | np .dtype | ExtensionDtype | None = None ,
84+ copy : bool = True ,
85+ ) -> FloatingArray : ...
86+ @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
31111def array (
32- data : Sequence [object ] ,
112+ data : Sequence [Any ] | np_ndarray | ExtensionArray | Index | Series ,
33113 dtype : str | np .dtype | ExtensionDtype | None = None ,
34114 copy : bool = True ,
35- ) -> ExtensionArray : ...
115+ ) -> NumpyExtensionArray : ...
0 commit comments