Skip to content

Commit 9aac8e3

Browse files
authored
reportIncompatibleMethodOverride (#802)
* reportIncompatibleMethodOverride * BooleanDtype.na_value is a property * fix Timestamp.combine tests * unpin pyright
1 parent 05d6a52 commit 9aac8e3

30 files changed

+119
-218
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
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.9.1
6+
rev: 23.10.0
77
hooks:
88
- id: black
99
- repo: https://github.com/PyCQA/isort
1010
rev: 5.12.0
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.0.292
14+
rev: v0.1.1
1515
hooks:
1616
- id: ruff
1717
args: [

pandas-stubs/_libs/tslibs/timedeltas.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ UnitChoices: TypeAlias = (
101101
)
102102

103103
class Timedelta(timedelta):
104-
min: ClassVar[Timedelta]
105-
max: ClassVar[Timedelta]
106-
resolution: ClassVar[Timedelta]
104+
min: ClassVar[Timedelta] # pyright: ignore[reportIncompatibleVariableOverride]
105+
max: ClassVar[Timedelta] # pyright: ignore[reportIncompatibleVariableOverride]
106+
resolution: ClassVar[ # pyright: ignore[reportIncompatibleVariableOverride]
107+
Timedelta
108+
]
107109
value: int
108110
def __new__(
109111
cls,

pandas-stubs/_libs/tslibs/timestamps.pyi

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ _Nonexistent: TypeAlias = (
4747
)
4848

4949
class Timestamp(datetime):
50-
min: ClassVar[Timestamp]
51-
max: ClassVar[Timestamp]
50+
min: ClassVar[Timestamp] # pyright: ignore[reportIncompatibleVariableOverride]
51+
max: ClassVar[Timestamp] # pyright: ignore[reportIncompatibleVariableOverride]
5252

53-
resolution: ClassVar[Timedelta]
53+
resolution: ClassVar[ # pyright: ignore[reportIncompatibleVariableOverride]
54+
Timedelta
55+
]
5456
value: int
5557
def __new__(
5658
cls,
@@ -117,7 +119,7 @@ class Timestamp(datetime):
117119
def utcnow(cls) -> Self: ...
118120
# error: Signature of "combine" incompatible with supertype "datetime"
119121
@classmethod
120-
def combine(cls, date: _date, time: _time) -> datetime: ... # type: ignore[override]
122+
def combine(cls, date: _date, time: _time) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
121123
@classmethod
122124
def fromisoformat(cls, date_string: str) -> Self: ...
123125
def strftime(self, format: str) -> str: ...
@@ -132,7 +134,7 @@ class Timestamp(datetime):
132134
# Override since fold is more precise than datetime.replace(fold:int)
133135
# Here it is restricted to be 0 or 1 using a Literal
134136
# Violation of Liskov substitution principle
135-
def replace( # type:ignore[override]
137+
def replace( # type:ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
136138
self,
137139
year: int | None = ...,
138140
month: int | None = ...,
@@ -148,7 +150,7 @@ class Timestamp(datetime):
148150
def ctime(self) -> str: ...
149151
def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ...
150152
@classmethod
151-
def strptime(cls, date_string: Never, format: Never) -> Never: ... # type: ignore[override]
153+
def strptime(cls, date_string: Never, format: Never) -> Never: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
152154
def utcoffset(self) -> timedelta | None: ...
153155
def tzname(self) -> str | None: ...
154156
def dst(self) -> timedelta | None: ...
@@ -207,7 +209,7 @@ class Timestamp(datetime):
207209
@overload
208210
def __sub__(self, other: TimedeltaSeries) -> TimestampSeries: ...
209211
@overload
210-
def __sub__(
212+
def __sub__( # pyright: ignore[reportIncompatibleMethodOverride]
211213
self, other: npt.NDArray[np.timedelta64]
212214
) -> npt.NDArray[np.datetime64]: ...
213215
@overload

pandas-stubs/core/arraylike.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ from pandas._libs.ops_dispatch import (
77
)
88

99
class OpsMixin:
10-
def __eq__(self, other: object) -> Self: ... # type: ignore[override]
11-
def __ne__(self, other: object) -> Self: ... # type: ignore[override]
10+
def __eq__(self, other: object) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
11+
def __ne__(self, other: object) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
1212
def __lt__(self, other: Any) -> Self: ...
1313
def __le__(self, other: Any) -> Self: ...
1414
def __gt__(self, other: Any) -> Self: ...

pandas-stubs/core/arrays/boolean.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import ClassVar
2-
31
import numpy as np
42
from pandas.core.arrays.masked import BaseMaskedArray as BaseMaskedArray
53

@@ -9,7 +7,8 @@ from pandas._typing import type_t
97
from pandas.core.dtypes.base import ExtensionDtype as ExtensionDtype
108

119
class BooleanDtype(ExtensionDtype):
12-
na_value: ClassVar[NAType]
10+
@property
11+
def na_value(self) -> NAType: ...
1312
@classmethod
1413
def construct_array_type(cls) -> type_t[BooleanArray]: ...
1514

pandas-stubs/core/arrays/datetimelike.pyi

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ from pandas.core.arrays.base import (
55
ExtensionArray,
66
ExtensionOpsMixin,
77
)
8-
from typing_extensions import Self
98

109
from pandas._libs import (
1110
NaT as NaT,
1211
NaTType as NaTType,
1312
)
14-
from pandas._typing import TakeIndexer
1513

1614
class DatelikeOps:
1715
def strftime(self, date_format): ...
@@ -38,13 +36,12 @@ class DatetimeLikeArrayMixin(ExtensionOpsMixin, ExtensionArray):
3836
def size(self) -> int: ...
3937
def __len__(self) -> int: ...
4038
def __getitem__(self, key): ...
41-
def __setitem__(self, key: int | Sequence[int] | Sequence[bool] | slice, value) -> None: ... # type: ignore[override]
39+
def __setitem__( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
40+
self, key: int | Sequence[int] | Sequence[bool] | slice, value
41+
) -> None: ...
4242
def astype(self, dtype, copy: bool = ...): ...
4343
def view(self, dtype=...): ...
4444
def unique(self): ...
45-
def take(
46-
self: Self, indices: TakeIndexer, *, allow_fill: bool = ..., fill_value=...
47-
) -> Self: ...
4845
def copy(self): ...
4946
def shift(self, periods: int = ..., fill_value=..., axis: int = ...): ...
5047
def searchsorted(self, value, side: str = ..., sorter=...): ...

pandas-stubs/core/arrays/datetimes.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DatetimeArray(DatetimeLikeArrayMixin, TimelikeOps, DatelikeOps):
1616
def __init__(self, values, dtype=..., freq=..., copy: bool = ...) -> None: ...
1717
# ignore in dtype() is from the pandas source
1818
@property
19-
def dtype(self) -> np.dtype | DatetimeTZDtype: ... # type: ignore[override]
19+
def dtype(self) -> np.dtype | DatetimeTZDtype: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
2020
@property
2121
def tz(self): ...
2222
@tz.setter

pandas-stubs/core/arrays/integer.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class _IntegerDtype(ExtensionDtype):
1414
def construct_array_type(cls) -> type[IntegerArray]: ...
1515

1616
class IntegerArray(BaseMaskedArray):
17-
def dtype(self): ...
17+
@property
18+
def dtype(self) -> _IntegerDtype: ...
1819
def __init__(self, values, mask, copy: bool = ...) -> None: ...
1920
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): ...
2021
def __setitem__(self, key, value) -> None: ...

pandas-stubs/core/arrays/interval.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ from pandas._typing import (
2020
)
2121

2222
class IntervalArray(IntervalMixin, ExtensionArray):
23-
ndim: int = ...
2423
can_hold_na: bool = ...
2524
def __new__(
2625
cls, data, closed=..., dtype=..., copy: bool = ..., verify_integrity: bool = ...
@@ -50,7 +49,7 @@ class IntervalArray(IntervalMixin, ExtensionArray):
5049
@property
5150
def size(self) -> int: ...
5251
def shift(self, periods: int = ..., fill_value: object = ...) -> IntervalArray: ...
53-
def take( # type: ignore[override]
52+
def take( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
5453
self: Self,
5554
indices: TakeIndexer,
5655
*,

pandas-stubs/core/arrays/masked.pyi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ from pandas.core.arrays import (
66

77
from pandas._typing import (
88
Scalar,
9-
TakeIndexer,
109
npt,
1110
)
1211

@@ -27,8 +26,5 @@ class BaseMaskedArray(ExtensionArray, ExtensionOpsMixin):
2726
def isna(self): ...
2827
@property
2928
def nbytes(self) -> int: ...
30-
def take(
31-
self, indexer: TakeIndexer, allow_fill: bool = ..., fill_value=...
32-
) -> BaseMaskedArray: ...
3329
def copy(self): ...
3430
def value_counts(self, dropna: bool = ...): ...

0 commit comments

Comments
 (0)