Skip to content

Commit 4c693f7

Browse files
committed
make CI pass
1 parent 5a6906c commit 4c693f7

File tree

10 files changed

+129
-72
lines changed

10 files changed

+129
-72
lines changed

pandas-stubs/core/arrays/base.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ from pandas._typing import (
1010
npt,
1111
)
1212

13-
from pandas.core.dtypes.dtypes import ExtensionDtype as ExtensionDtype
13+
from pandas.core.dtypes.dtypes import ExtensionDtype
1414

1515
class ExtensionArray:
1616
def __getitem__(self, item) -> Any: ...
17-
def __setitem__(self, key: int | slice | np.ndarray, value) -> None: ...
17+
def __setitem__(self, key: int | slice | np.ndarray, value: Self) -> None: ...
1818
def __len__(self) -> int: ...
1919
def __iter__(self): ...
2020
def __contains__(self, item: object) -> bool | np.bool_: ...

pandas-stubs/core/arrays/boolean.pyi

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from typing import (
66

77
import numpy as np
88
from pandas.core.arrays import ExtensionArray
9-
from pandas.core.arrays.masked import BaseMaskedArray as BaseMaskedArray
9+
from pandas.core.arrays.masked import BaseMaskedArray
1010
from typing_extensions import TypeAlias
1111

1212
from pandas._libs.missing import NAType
@@ -15,7 +15,7 @@ from pandas._typing import (
1515
type_t,
1616
)
1717

18-
from pandas.core.dtypes.base import ExtensionDtype as ExtensionDtype
18+
from pandas.core.dtypes.base import ExtensionDtype
1919

2020
class BooleanDtype(ExtensionDtype):
2121
na_value: ClassVar[NAType]
@@ -44,7 +44,7 @@ class BooleanArray(BaseMaskedArray):
4444
| npt.NDArray[np.bool_]
4545
| BooleanArray,
4646
) -> None: ...
47-
@overload # type: ignore[override]
47+
@overload
4848
def __getitem__(self, item: int) -> bool | NAType: ...
4949
@overload
5050
def __getitem__(self, item: _ArrayKey) -> BooleanArray: ...
@@ -55,4 +55,3 @@ class BooleanArray(BaseMaskedArray):
5555
) -> np.ndarray | ExtensionArray: ...
5656
def any(self, skipna: bool = ..., **kwargs) -> bool: ...
5757
def all(self, skipna: bool = ..., **kwargs) -> bool: ...
58-
def __setitem__(self, key, value) -> None: ...

pandas-stubs/core/arrays/integer.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ from pandas.arrays import (
1212
StringArray,
1313
)
1414
from pandas.core.arrays.masked import BaseMaskedArray
15-
from typing_extensions import Self
1615

1716
from pandas._libs.missing import NAType
1817
from pandas._typing import npt
@@ -26,7 +25,7 @@ class _IntegerDtype(ExtensionDtype):
2625
@property
2726
def itemsize(self) -> int: ...
2827
@classmethod
29-
def construct_array_type(cls) -> type[Self]: ...
28+
def construct_array_type(cls) -> type[IntegerArray]: ...
3029
def __from_arrow__(self, array): ...
3130

3231
class IntegerArray(BaseMaskedArray):
@@ -45,7 +44,7 @@ class IntegerArray(BaseMaskedArray):
4544
key: Sequence[int] | slice | npt.NDArray[np.integer],
4645
value: float | NAType | Sequence[float | NAType] | npt.NDArray[np.integer],
4746
) -> None: ...
48-
@overload # type: ignore[override]
47+
@overload
4948
def __getitem__(self, item: int) -> int | NAType: ...
5049
@overload
5150
def __getitem__(

pandas-stubs/core/arrays/interval.pyi

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ from pandas import (
1212
Index,
1313
Series,
1414
)
15-
from pandas.core.arrays.base import ExtensionArray as ExtensionArray
15+
from pandas.core.arrays.base import ExtensionArray
16+
from pandas.core.base import IndexOpsMixin
1617
from typing_extensions import Self
1718

1819
from pandas._libs.interval import (
19-
Interval as Interval,
20-
IntervalMixin as IntervalMixin,
20+
Interval,
21+
IntervalMixin,
2122
)
2223
from pandas._typing import (
2324
Axis,
@@ -41,43 +42,90 @@ class IntervalArray(IntervalMixin, ExtensionArray, Generic[IntervalT]):
4142
@overload
4243
@classmethod
4344
def from_breaks(
44-
cls, breaks: Sequence[int], closed: str = ..., copy: bool = ..., dtype=...
45+
cls,
46+
breaks: Sequence[int] | npt.NDArray[np.integer] | IndexOpsMixin[int],
47+
closed: Literal["left", "right", "both", "neither"] = ...,
48+
copy: bool = ...,
49+
dtype: pd.IntervalDtype = ...,
4550
) -> IntervalArray[Interval[int]]: ...
4651
@overload
4752
@classmethod
4853
def from_breaks(
49-
cls, breaks: Sequence[float], closed: str = ..., copy: bool = ..., dtype=...
54+
cls,
55+
breaks: Sequence[float] | npt.NDArray[np.floating] | IndexOpsMixin[float],
56+
closed: Literal["left", "right", "both", "neither"] = ...,
57+
copy: bool = ...,
58+
dtype: pd.IntervalDtype = ...,
5059
) -> IntervalArray[Interval[float]]: ...
5160
@overload
5261
@classmethod
5362
def from_breaks(
5463
cls,
55-
breaks: Sequence[pd.Timestamp | np.datetime64 | dt.datetime],
56-
closed: str = ...,
64+
breaks: Sequence[np.datetime64 | dt.datetime] | IndexOpsMixin[pd.Timestamp],
65+
closed: Literal["left", "right", "both", "neither"] = ...,
5766
copy: bool = ...,
58-
dtype=...,
67+
dtype: pd.IntervalDtype = ...,
5968
) -> IntervalArray[Interval[pd.Timestamp]]: ...
6069
@overload
6170
@classmethod
6271
def from_breaks(
6372
cls,
64-
breaks: Sequence[pd.Timedelta | np.timedelta64 | dt.timedelta],
65-
closed: str = ...,
73+
breaks: Sequence[np.timedelta64 | dt.timedelta] | IndexOpsMixin[pd.Timedelta],
74+
closed: Literal["left", "right", "both", "neither"] = ...,
6675
copy: bool = ...,
67-
dtype=...,
76+
dtype: pd.IntervalDtype = ...,
6877
) -> IntervalArray[Interval[pd.Timedelta]]: ...
78+
@overload
6979
@classmethod
7080
def from_arrays(
71-
cls, left, right, closed: str = ..., copy: bool = ..., dtype=...
72-
) -> IntervalArray: ...
81+
cls,
82+
left: Sequence[int] | npt.NDArray[np.integer] | IndexOpsMixin[int],
83+
right: Sequence[int] | npt.NDArray[np.integer] | IndexOpsMixin[int],
84+
closed: Literal["left", "right", "both", "neither"] = ...,
85+
copy: bool = ...,
86+
dtype: pd.IntervalDtype = ...,
87+
) -> IntervalArray[Interval[int]]: ...
88+
@overload
89+
@classmethod
90+
def from_arrays(
91+
cls,
92+
left: Sequence[float] | npt.NDArray[np.floating] | IndexOpsMixin[float],
93+
right: Sequence[float] | npt.NDArray[np.floating] | IndexOpsMixin[float],
94+
closed: Literal["left", "right", "both", "neither"] = ...,
95+
copy: bool = ...,
96+
dtype: pd.IntervalDtype = ...,
97+
) -> IntervalArray[Interval[float]]: ...
98+
@overload
99+
@classmethod
100+
def from_arrays(
101+
cls,
102+
left: Sequence[np.datetime64 | dt.datetime] | pd.DatetimeIndex,
103+
right: Sequence[np.datetime64 | dt.datetime] | pd.DatetimeIndex,
104+
closed: Literal["left", "right", "both", "neither"] = ...,
105+
copy: bool = ...,
106+
dtype: pd.IntervalDtype = ...,
107+
) -> IntervalArray[Interval[pd.Timestamp]]: ...
108+
@overload
109+
@classmethod
110+
def from_arrays(
111+
cls,
112+
left: Sequence[np.timedelta64 | dt.timedelta] | pd.TimedeltaIndex,
113+
right: Sequence[np.timedelta64 | dt.timedelta] | pd.TimedeltaIndex,
114+
closed: Literal["left", "right", "both", "neither"] = ...,
115+
copy: bool = ...,
116+
dtype: pd.IntervalDtype = ...,
117+
) -> IntervalArray[Interval[pd.Timedelta]]: ...
73118
@classmethod
74119
def from_tuples(
75-
cls, data, closed: str = ..., copy: bool = ..., dtype=...
120+
cls,
121+
data,
122+
closed: Literal["left", "right", "both", "neither"] = ...,
123+
copy: bool = ...,
124+
dtype: pd.IntervalDtype = ...,
76125
) -> IntervalArray: ...
77126
def __iter__(self) -> IntervalT: ...
78127
def __len__(self) -> int: ...
79128
def __getitem__(self, value: IntervalT): ...
80-
def __setitem__(self, key: int, value: IntervalT) -> None: ...
81129
def __eq__(self, other): ...
82130
def __ne__(self, other): ...
83131
def fillna(self, value=..., method=..., limit=...): ...

pandas-stubs/core/arrays/period.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ from pandas.core.arrays.datetimelike import (
88

99
from pandas._libs.tslibs import Period
1010
from pandas._libs.tslibs.timestamps import Timestamp
11-
from pandas._typing import npt as npt
1211

1312
from pandas.tseries.offsets import Tick
1413

pandas-stubs/core/arrays/string_.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class StringArray(PandasArray):
4848
| npt.NDArray[np.string_]
4949
| StringArray,
5050
) -> None: ...
51-
@overload # type: ignore[override]
51+
@overload
5252
def __getitem__(self, item: int) -> str | NAType: ...
5353
@overload
5454
def __getitem__(self, item: _ArrayKey) -> StringArray: ...

pandas-stubs/core/series.pyi

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
221221
cls,
222222
data: DatetimeIndex | Sequence[Timestamp | np.datetime64 | datetime],
223223
index: Axes | None = ...,
224+
*,
224225
dtype: TimestampDtypeArg = ...,
225226
name: Hashable | None = ...,
226227
copy: bool = ...,
@@ -240,6 +241,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
240241
cls,
241242
data: PeriodIndex,
242243
index: Axes | None = ...,
244+
*,
243245
dtype: PeriodDtype = ...,
244246
name: Hashable | None = ...,
245247
copy: bool = ...,
@@ -249,6 +251,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
249251
cls,
250252
data: TimedeltaIndex | Sequence[Timedelta | np.timedelta64 | timedelta],
251253
index: Axes | None = ...,
254+
*,
252255
dtype: TimedeltaDtypeArg = ...,
253256
name: Hashable | None = ...,
254257
copy: bool = ...,
@@ -260,6 +263,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
260263
| Interval[_OrderableT]
261264
| Sequence[Interval[_OrderableT]],
262265
index: Axes | None = ...,
266+
*,
263267
dtype: Literal["Interval"] = ...,
264268
name: Hashable | None = ...,
265269
copy: bool = ...,
@@ -268,8 +272,9 @@ class Series(IndexOpsMixin[S1], NDFrame):
268272
def __new__(
269273
cls,
270274
data: object | _ListLike | Series[S1] | dict[int, S1] | dict[_str, S1] | None,
271-
dtype: type[S1],
272275
index: Axes | None = ...,
276+
*,
277+
dtype: type[S1],
273278
name: Hashable | None = ...,
274279
copy: bool = ...,
275280
) -> Self: ...
@@ -278,6 +283,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
278283
cls,
279284
data: Series[S1] | dict[int, S1] | dict[_str, S1] = ...,
280285
index: Axes | None = ...,
286+
*,
281287
dtype: Dtype = ...,
282288
name: Hashable | None = ...,
283289
copy: bool = ...,
@@ -287,6 +293,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
287293
cls,
288294
data: object | _ListLike | None = ...,
289295
index: Axes | None = ...,
296+
*,
290297
dtype: Dtype = ...,
291298
name: Hashable | None = ...,
292299
copy: bool = ...,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ numpy = [
3939
]
4040

4141
[tool.poetry.dev-dependencies]
42-
mypy = "1.5.0"
42+
mypy = "1.5.1"
4343
pandas = "2.0.3"
4444
pyarrow = ">=10.0.1"
4545
pytest = ">=7.1.2"

tests/extension/decimal/array.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import decimal
44
import numbers
55
import sys
6+
from typing import (
7+
Sequence,
8+
cast,
9+
)
610

711
import numpy as np
812
import pandas as pd
@@ -200,13 +204,15 @@ def astype(self, dtype, copy=True):
200204

201205
return super().astype(dtype, copy=copy)
202206

203-
def __setitem__(self, key, value) -> None:
207+
def __setitem__(
208+
self, key, value: DecimalArray | decimal.Decimal | Sequence[decimal.Decimal]
209+
) -> None:
204210
if is_list_like(value):
205211
if is_scalar(key):
206212
raise ValueError("setting an array element with a sequence.")
207-
value = [decimal.Decimal(v) for v in value]
213+
value = [decimal.Decimal(v) for v in cast(Sequence[decimal.Decimal], value)]
208214
else:
209-
value = decimal.Decimal(value)
215+
value = decimal.Decimal(cast(decimal.Decimal, value))
210216

211217
key = check_array_indexer(self, key)
212218
self._data[key] = value

0 commit comments

Comments
 (0)