File tree Expand file tree Collapse file tree 2 files changed +36
-7
lines changed Expand file tree Collapse file tree 2 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ from pandas._typing import (
4949 StrDtypeArg ,
5050 TimedeltaDtypeArg ,
5151 TimestampDtypeArg ,
52+ UIntDtypeArg ,
5253 np_ndarray ,
5354 np_ndarray_anyint ,
5455 np_ndarray_bool ,
@@ -85,7 +86,7 @@ def array( # type: ignore[overload-overlap]
8586@overload
8687def array ( # type: ignore[overload-overlap]
8788 data : Sequence [int | np .integer | NAType | None ] | np_ndarray_anyint | IntegerArray ,
88- dtype : IntDtypeArg | None = None ,
89+ dtype : IntDtypeArg | UIntDtypeArg | None = None ,
8990 copy : bool = True ,
9091) -> IntegerArray : ...
9192@overload
@@ -137,12 +138,8 @@ def array( # type: ignore[overload-overlap]
137138) -> PeriodArray : ...
138139@overload
139140def array ( # type: ignore[overload-overlap]
140- data : (
141- Sequence [IntervalT | NAType | None ]
142- | IntervalIndex
143- | Series [Interval ]
144- | IntervalArray
145- ),
141+ # float("nan") also works, but I don't know how to put it in
142+ data : Sequence [IntervalT | None ] | IntervalArray | IntervalIndex | Series [Interval ],
146143 dtype : IntervalDtype | None = None ,
147144 copy : bool = True ,
148145) -> IntervalArray : ...
Original file line number Diff line number Diff line change 1+ import pandas as pd
2+ from pandas .core .arrays .interval import IntervalArray
3+ from typing_extensions import assert_type
4+
5+ from tests import check
6+
7+
8+ def test_constructor () -> None :
9+ itv = pd .Interval (0 , 1 )
10+ check (
11+ assert_type ( # type: ignore[assert-type] # I do not understand
12+ pd .array ([itv ]), IntervalArray
13+ ),
14+ IntervalArray ,
15+ )
16+ check (
17+ assert_type ( # type: ignore[assert-type] # I do not understand
18+ pd .array ([itv , None ]), IntervalArray
19+ ),
20+ IntervalArray ,
21+ )
22+
23+ check (
24+ assert_type ( # type: ignore[assert-type] # I do not understand
25+ pd .array (pd .array ([itv ])), IntervalArray
26+ ),
27+ IntervalArray ,
28+ )
29+
30+ check (assert_type (pd .array (pd .Index ([itv ])), IntervalArray ), IntervalArray )
31+
32+ check (assert_type (pd .array (pd .Series ([itv ])), IntervalArray ), IntervalArray )
You can’t perform that action at this time.
0 commit comments