Skip to content

Commit afb0db5

Browse files
authored
Mypy 1.7.1 and fix #827 (#829)
* mypy 1.7.1 * fix 827, towards 826
1 parent a950dbd commit afb0db5

16 files changed

+91
-79
lines changed

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ ci:
33
autofix_prs: false
44
repos:
55
- repo: https://github.com/python/black
6-
rev: 23.11.0
6+
rev: 23.12.0
77
hooks:
88
- id: black
99
- repo: https://github.com/PyCQA/isort
10-
rev: 5.13.0
10+
rev: 5.13.2
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.1.7
14+
rev: v0.1.8
1515
hooks:
1616
- id: ruff
1717
args: [

pandas-stubs/_libs/interval.pyi

+6-6
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,19 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
199199
@overload
200200
def __le__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ...
201201
@overload
202-
def __eq__(self, other: Interval[_OrderableT]) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
202+
def __eq__(self, other: Interval[_OrderableT]) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
203203
@overload
204-
def __eq__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc]
204+
def __eq__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[overload-overlap]
205205
@overload
206-
def __eq__(self, other: Series[_OrderableT]) -> Series[bool]: ... # type: ignore[misc]
206+
def __eq__(self, other: Series[_OrderableT]) -> Series[bool]: ... # type: ignore[overload-overlap]
207207
@overload
208208
def __eq__(self, other: object) -> Literal[False]: ...
209209
@overload
210-
def __ne__(self, other: Interval[_OrderableT]) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
210+
def __ne__(self, other: Interval[_OrderableT]) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
211211
@overload
212-
def __ne__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc]
212+
def __ne__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[overload-overlap]
213213
@overload
214-
def __ne__(self, other: Series[_OrderableT]) -> Series[bool]: ... # type: ignore[misc]
214+
def __ne__(self, other: Series[_OrderableT]) -> Series[bool]: ... # type: ignore[overload-overlap]
215215
@overload
216216
def __ne__(self, other: object) -> Literal[True]: ...
217217

pandas-stubs/_libs/tslibs/nattype.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class _NatComparison:
2222

2323
class NaTType:
2424
value: np.int64
25+
def __hash__(self) -> int: ...
2526
def asm8(self) -> np.datetime64: ...
2627
def to_datetime64(self) -> np.datetime64: ...
2728
def to_numpy(

pandas-stubs/_libs/tslibs/period.pyi

+6-6
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ class Period(PeriodMixin):
9999
# ignore[misc] here because we know all other comparisons
100100
# are False, so we use Literal[False]
101101
@overload
102-
def __eq__(self, other: Period) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
102+
def __eq__(self, other: Period) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
103103
@overload
104-
def __eq__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ... # type: ignore[misc]
104+
def __eq__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ... # type: ignore[overload-overlap]
105105
@overload
106-
def __eq__(self, other: PeriodSeries) -> Series[bool]: ... # type: ignore[misc]
106+
def __eq__(self, other: PeriodSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
107107
@overload
108108
def __eq__(self, other: object) -> Literal[False]: ...
109109
@overload
@@ -133,11 +133,11 @@ class Period(PeriodMixin):
133133
# ignore[misc] here because we know all other comparisons
134134
# are False, so we use Literal[False]
135135
@overload
136-
def __ne__(self, other: Period) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
136+
def __ne__(self, other: Period) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
137137
@overload
138-
def __ne__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ... # type: ignore[misc]
138+
def __ne__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ... # type: ignore[overload-overlap]
139139
@overload
140-
def __ne__(self, other: PeriodSeries) -> Series[bool]: ... # type: ignore[misc]
140+
def __ne__(self, other: PeriodSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
141141
@overload
142142
def __ne__(self, other: object) -> Literal[True]: ...
143143
# Ignored due to indecipherable error from mypy:

pandas-stubs/_libs/tslibs/timedeltas.pyi

+6-6
Original file line numberDiff line numberDiff line change
@@ -308,22 +308,22 @@ class Timedelta(timedelta):
308308
def __rtruediv__(self, other: timedelta | Timedelta | NaTType) -> float: ...
309309
# Override due to more types supported than dt.timedelta
310310
@overload
311-
def __eq__(self, other: timedelta | Timedelta | np.timedelta64) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
311+
def __eq__(self, other: timedelta | Timedelta | np.timedelta64) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
312312
@overload
313-
def __eq__(self, other: TimedeltaSeries | Series[pd.Timedelta]) -> Series[bool]: ... # type: ignore[misc]
313+
def __eq__(self, other: TimedeltaSeries | Series[pd.Timedelta]) -> Series[bool]: ... # type: ignore[overload-overlap]
314314
@overload
315-
def __eq__( # type: ignore[misc]
315+
def __eq__( # type: ignore[overload-overlap]
316316
self, other: TimedeltaIndex | npt.NDArray[np.timedelta64]
317317
) -> npt.NDArray[np.bool_]: ...
318318
@overload
319319
def __eq__(self, other: object) -> Literal[False]: ...
320320
# Override due to more types supported than dt.timedelta
321321
@overload
322-
def __ne__(self, other: timedelta | Timedelta | np.timedelta64) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
322+
def __ne__(self, other: timedelta | Timedelta | np.timedelta64) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
323323
@overload
324-
def __ne__(self, other: TimedeltaSeries | Series[pd.Timedelta]) -> Series[bool]: ... # type: ignore[misc]
324+
def __ne__(self, other: TimedeltaSeries | Series[pd.Timedelta]) -> Series[bool]: ... # type: ignore[overload-overlap]
325325
@overload
326-
def __ne__( # type: ignore[misc]
326+
def __ne__( # type: ignore[overload-overlap]
327327
self, other: TimedeltaIndex | npt.NDArray[np.timedelta64]
328328
) -> npt.NDArray[np.bool_]: ...
329329
@overload

pandas-stubs/_libs/tslibs/timestamps.pyi

+6-6
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,19 @@ class Timestamp(datetime):
213213
self, other: npt.NDArray[np.timedelta64]
214214
) -> npt.NDArray[np.datetime64]: ...
215215
@overload
216-
def __eq__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
216+
def __eq__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
217217
@overload
218-
def __eq__(self, other: TimestampSeries) -> Series[bool]: ... # type: ignore[misc]
218+
def __eq__(self, other: TimestampSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
219219
@overload
220-
def __eq__(self, other: npt.NDArray[np.datetime64] | Index) -> np_ndarray_bool: ... # type: ignore[misc]
220+
def __eq__(self, other: npt.NDArray[np.datetime64] | Index) -> np_ndarray_bool: ... # type: ignore[overload-overlap]
221221
@overload
222222
def __eq__(self, other: object) -> Literal[False]: ...
223223
@overload
224-
def __ne__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
224+
def __ne__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
225225
@overload
226-
def __ne__(self, other: TimestampSeries) -> Series[bool]: ... # type: ignore[misc]
226+
def __ne__(self, other: TimestampSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
227227
@overload
228-
def __ne__(self, other: npt.NDArray[np.datetime64] | Index) -> np_ndarray_bool: ... # type: ignore[misc]
228+
def __ne__(self, other: npt.NDArray[np.datetime64] | Index) -> np_ndarray_bool: ... # type: ignore[overload-overlap]
229229
@overload
230230
def __ne__(self, other: object) -> Literal[True]: ...
231231
def __hash__(self) -> int: ...

pandas-stubs/core/algorithms.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ from pandas._typing import (
2525
# with extension types return the same type while standard type return ndarray
2626

2727
@overload
28-
def unique(values: PeriodIndex) -> PeriodIndex: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
28+
def unique(values: PeriodIndex) -> PeriodIndex: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
2929
@overload
30-
def unique(values: CategoricalIndex) -> CategoricalIndex: ... # type: ignore[misc]
30+
def unique(values: CategoricalIndex) -> CategoricalIndex: ... # type: ignore[overload-overlap]
3131
@overload
32-
def unique(values: IntervalIndex[IntervalT]) -> IntervalIndex[IntervalT]: ... # type: ignore[misc]
32+
def unique(values: IntervalIndex[IntervalT]) -> IntervalIndex[IntervalT]: ... # type: ignore[overload-overlap]
3333
@overload
3434
def unique(values: Index) -> np.ndarray: ...
3535
@overload

pandas-stubs/core/frame.pyi

+6-6
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ class DataFrame(NDFrame, OpsMixin):
273273
na_value: Scalar = ...,
274274
) -> np.ndarray: ...
275275
@overload
276-
def to_dict( # type: ignore[misc]
276+
def to_dict( # type: ignore[overload-overlap]
277277
self,
278278
orient: Literal["records"],
279279
*,
@@ -289,31 +289,31 @@ class DataFrame(NDFrame, OpsMixin):
289289
index: Literal[True] = ...,
290290
) -> list[dict[Hashable, Any]]: ...
291291
@overload
292-
def to_dict( # type: ignore[misc]
292+
def to_dict( # type: ignore[overload-overlap]
293293
self,
294294
orient: Literal["dict", "list", "series", "index"],
295295
*,
296296
into: MutableMapping | type[MutableMapping],
297297
index: Literal[True] = ...,
298298
) -> MutableMapping[Hashable, Any]: ...
299299
@overload
300-
def to_dict( # type: ignore[misc]
300+
def to_dict( # type: ignore[overload-overlap]
301301
self,
302302
orient: Literal["split", "tight"],
303303
*,
304304
into: MutableMapping | type[MutableMapping],
305305
index: bool = ...,
306306
) -> MutableMapping[Hashable, Any]: ...
307307
@overload
308-
def to_dict( # type: ignore[misc]
308+
def to_dict( # type: ignore[overload-overlap]
309309
self,
310310
orient: Literal["dict", "list", "series", "index"] = ...,
311311
*,
312312
into: MutableMapping | type[MutableMapping],
313313
index: Literal[True] = ...,
314314
) -> MutableMapping[Hashable, Any]: ...
315315
@overload
316-
def to_dict( # type: ignore[misc]
316+
def to_dict( # type: ignore[overload-overlap]
317317
self,
318318
orient: Literal["split", "tight"] = ...,
319319
*,
@@ -558,7 +558,7 @@ class DataFrame(NDFrame, OpsMixin):
558558
def T(self) -> DataFrame: ...
559559
def __getattr__(self, name: str) -> Series: ...
560560
@overload
561-
def __getitem__(self, key: Scalar | tuple[Hashable, ...]) -> Series: ... # type: ignore[misc]
561+
def __getitem__(self, key: Scalar | tuple[Hashable, ...]) -> Series: ... # type: ignore[overload-overlap]
562562
@overload
563563
def __getitem__(self, key: Iterable[Hashable] | slice) -> DataFrame: ...
564564
@overload

pandas-stubs/core/groupby/generic.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class DataFrameGroupBy(GroupBy, Generic[ByT]):
145145
def all(self, skipna: bool = ...) -> DataFrame: ...
146146
# error: Overload 3 for "apply" will never be used because its parameters overlap overload 1
147147
@overload
148-
def apply( # type: ignore[misc]
148+
def apply( # type: ignore[overload-overlap]
149149
self,
150150
func: Callable[[DataFrame], Scalar | list | dict],
151151
*args,
@@ -167,7 +167,7 @@ class DataFrameGroupBy(GroupBy, Generic[ByT]):
167167
) -> DataFrame: ...
168168
# error: overload 1 overlaps overload 2 because of different return types
169169
@overload
170-
def aggregate(self, arg: Literal["size"]) -> Series: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
170+
def aggregate(self, arg: Literal["size"]) -> Series: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
171171
@overload
172172
def aggregate(self, arg: AggFuncTypeFrame = ..., *args, **kwargs) -> DataFrame: ...
173173
agg = aggregate

pandas-stubs/core/indexes/base.pyi

+15-15
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Index(IndexOpsMixin[S1]):
6666
__hash__: ClassVar[None] # type: ignore[assignment]
6767
# overloads with additional dtypes
6868
@overload
69-
def __new__( # type: ignore[misc]
69+
def __new__( # type: ignore[overload-overlap]
7070
cls,
7171
data: Sequence[int | np.integer] | IndexOpsMixin[int] | np_ndarray_anyint,
7272
*,
@@ -77,7 +77,7 @@ class Index(IndexOpsMixin[S1]):
7777
**kwargs,
7878
) -> Index[int]: ...
7979
@overload
80-
def __new__( # type: ignore[misc]
80+
def __new__( # type: ignore[overload-overlap]
8181
cls,
8282
data: Iterable,
8383
*,
@@ -88,7 +88,7 @@ class Index(IndexOpsMixin[S1]):
8888
**kwargs,
8989
) -> Index[int]: ...
9090
@overload
91-
def __new__( # type: ignore[misc]
91+
def __new__( # type: ignore[overload-overlap]
9292
cls,
9393
data: Sequence[float | np.floating] | IndexOpsMixin[float] | np_ndarray_float,
9494
*,
@@ -99,7 +99,7 @@ class Index(IndexOpsMixin[S1]):
9999
**kwargs,
100100
) -> Index[float]: ...
101101
@overload
102-
def __new__( # type: ignore[misc]
102+
def __new__( # type: ignore[overload-overlap]
103103
cls,
104104
data: Iterable,
105105
*,
@@ -110,7 +110,7 @@ class Index(IndexOpsMixin[S1]):
110110
**kwargs,
111111
) -> Index[float]: ...
112112
@overload
113-
def __new__( # type: ignore[misc]
113+
def __new__( # type: ignore[overload-overlap]
114114
cls,
115115
data: Sequence[complex | np.complexfloating]
116116
| IndexOpsMixin[complex]
@@ -123,7 +123,7 @@ class Index(IndexOpsMixin[S1]):
123123
**kwargs,
124124
) -> Index[complex]: ...
125125
@overload
126-
def __new__( # type: ignore[misc]
126+
def __new__( # type: ignore[overload-overlap]
127127
cls,
128128
data: Iterable,
129129
*,
@@ -135,7 +135,7 @@ class Index(IndexOpsMixin[S1]):
135135
) -> Index[complex]: ...
136136
# special overloads with dedicated Index-subclasses
137137
@overload
138-
def __new__( # type: ignore[misc]
138+
def __new__( # type: ignore[overload-overlap]
139139
cls,
140140
data: Sequence[np.datetime64 | datetime] | IndexOpsMixin[datetime],
141141
*,
@@ -146,7 +146,7 @@ class Index(IndexOpsMixin[S1]):
146146
**kwargs,
147147
) -> DatetimeIndex: ...
148148
@overload
149-
def __new__( # type: ignore[misc]
149+
def __new__( # type: ignore[overload-overlap]
150150
cls,
151151
data: Iterable,
152152
*,
@@ -157,7 +157,7 @@ class Index(IndexOpsMixin[S1]):
157157
**kwargs,
158158
) -> DatetimeIndex: ...
159159
@overload
160-
def __new__( # type: ignore[misc]
160+
def __new__( # type: ignore[overload-overlap]
161161
cls,
162162
data: Sequence[Period] | IndexOpsMixin[Period],
163163
*,
@@ -168,7 +168,7 @@ class Index(IndexOpsMixin[S1]):
168168
**kwargs,
169169
) -> PeriodIndex: ...
170170
@overload
171-
def __new__( # type: ignore[misc]
171+
def __new__( # type: ignore[overload-overlap]
172172
cls,
173173
data: Iterable,
174174
*,
@@ -179,7 +179,7 @@ class Index(IndexOpsMixin[S1]):
179179
**kwargs,
180180
) -> PeriodIndex: ...
181181
@overload
182-
def __new__( # type: ignore[misc]
182+
def __new__( # type: ignore[overload-overlap]
183183
cls,
184184
data: Sequence[np.timedelta64 | timedelta] | IndexOpsMixin[timedelta],
185185
*,
@@ -190,7 +190,7 @@ class Index(IndexOpsMixin[S1]):
190190
**kwargs,
191191
) -> TimedeltaIndex: ...
192192
@overload
193-
def __new__( # type: ignore[misc]
193+
def __new__( # type: ignore[overload-overlap]
194194
cls,
195195
data: Iterable,
196196
*,
@@ -201,7 +201,7 @@ class Index(IndexOpsMixin[S1]):
201201
**kwargs,
202202
) -> TimedeltaIndex: ...
203203
@overload
204-
def __new__( # type: ignore[misc]
204+
def __new__( # type: ignore[overload-overlap]
205205
cls,
206206
data: Sequence[Interval[_OrderableT]] | IndexOpsMixin[Interval[_OrderableT]],
207207
*,
@@ -212,7 +212,7 @@ class Index(IndexOpsMixin[S1]):
212212
**kwargs,
213213
) -> IntervalIndex[Interval[_OrderableT]]: ...
214214
@overload
215-
def __new__( # type: ignore[misc]
215+
def __new__( # type: ignore[overload-overlap]
216216
cls,
217217
data: Iterable,
218218
*,
@@ -421,7 +421,7 @@ class Index(IndexOpsMixin[S1]):
421421
def __gt__(self, other: Self | S1) -> np_ndarray_bool: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
422422
# overwrite inherited methods from OpsMixin
423423
@overload
424-
def __mul__( # type: ignore[misc]
424+
def __mul__( # type: ignore[overload-overlap]
425425
self: Index[int] | Index[float], other: timedelta
426426
) -> TimedeltaIndex: ...
427427
@overload

pandas-stubs/core/indexes/interval.pyi

+6-6
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class IntervalIndex(ExtensionIndex[IntervalT], IntervalMixin):
212212
) -> IntervalIndex[pd.Interval[pd.Timedelta]]: ...
213213
def to_tuples(self, na_tuple: bool = ...) -> pd.Index: ...
214214
@overload
215-
def __contains__(self, key: IntervalT) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
215+
def __contains__(self, key: IntervalT) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
216216
@overload
217217
def __contains__(self, key: object) -> Literal[False]: ...
218218
def astype(self, dtype: DtypeArg, copy: bool = ...) -> IntervalIndex: ...
@@ -289,17 +289,17 @@ class IntervalIndex(ExtensionIndex[IntervalT], IntervalMixin):
289289
@overload
290290
def __lt__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ...
291291
@overload # type: ignore[override]
292-
def __eq__(self, other: IntervalT | IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
292+
def __eq__(self, other: IntervalT | IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
293293
@overload
294-
def __eq__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ... # type: ignore[misc]
294+
def __eq__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ... # type: ignore[overload-overlap]
295295
@overload
296296
def __eq__( # pyright: ignore[reportIncompatibleMethodOverride]
297297
self, other: object
298298
) -> Literal[False]: ...
299299
@overload # type: ignore[override]
300-
def __ne__(self, other: IntervalT | IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
300+
def __ne__(self, other: IntervalT | IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
301301
@overload
302-
def __ne__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ... # type: ignore[misc]
302+
def __ne__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ... # type: ignore[overload-overlap]
303303
@overload
304304
def __ne__( # pyright: ignore[reportIncompatibleMethodOverride]
305305
self, other: object
@@ -308,7 +308,7 @@ class IntervalIndex(ExtensionIndex[IntervalT], IntervalMixin):
308308
# misc here because int and float overlap but interval has distinct types
309309
# int gets hit first and so the correct type is returned
310310
@overload
311-
def interval_range( # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
311+
def interval_range( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
312312
start: int = ...,
313313
end: int = ...,
314314
periods: int | None = ...,

0 commit comments

Comments
 (0)