Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reportIncompatibleMethodOverride #802

Merged
merged 5 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ ci:
autofix_prs: false
repos:
- repo: https://github.com/python/black
rev: 23.9.1
rev: 23.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.1
hooks:
- id: ruff
args: [
Expand Down
8 changes: 5 additions & 3 deletions pandas-stubs/_libs/tslibs/timedeltas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ UnitChoices: TypeAlias = (
)

class Timedelta(timedelta):
min: ClassVar[Timedelta]
max: ClassVar[Timedelta]
resolution: ClassVar[Timedelta]
min: ClassVar[Timedelta] # pyright: ignore[reportIncompatibleVariableOverride]
max: ClassVar[Timedelta] # pyright: ignore[reportIncompatibleVariableOverride]
resolution: ClassVar[ # pyright: ignore[reportIncompatibleVariableOverride]
Timedelta
]
value: int
def __new__(
cls,
Expand Down
16 changes: 9 additions & 7 deletions pandas-stubs/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ _Nonexistent: TypeAlias = (
)

class Timestamp(datetime):
min: ClassVar[Timestamp]
max: ClassVar[Timestamp]
min: ClassVar[Timestamp] # pyright: ignore[reportIncompatibleVariableOverride]
max: ClassVar[Timestamp] # pyright: ignore[reportIncompatibleVariableOverride]

resolution: ClassVar[Timedelta]
resolution: ClassVar[ # pyright: ignore[reportIncompatibleVariableOverride]
Timedelta
]
value: int
def __new__(
cls,
Expand Down Expand Up @@ -117,7 +119,7 @@ class Timestamp(datetime):
def utcnow(cls) -> Self: ...
# error: Signature of "combine" incompatible with supertype "datetime"
@classmethod
def combine(cls, date: _date, time: _time) -> datetime: ... # type: ignore[override]
def combine(cls, date: _date, time: _time) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
@classmethod
def fromisoformat(cls, date_string: str) -> Self: ...
def strftime(self, format: str) -> str: ...
Expand All @@ -132,7 +134,7 @@ class Timestamp(datetime):
# Override since fold is more precise than datetime.replace(fold:int)
# Here it is restricted to be 0 or 1 using a Literal
# Violation of Liskov substitution principle
def replace( # type:ignore[override]
def replace( # type:ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
self,
year: int | None = ...,
month: int | None = ...,
Expand All @@ -148,7 +150,7 @@ class Timestamp(datetime):
def ctime(self) -> str: ...
def isoformat(self, sep: str = ..., timespec: str = ...) -> str: ...
@classmethod
def strptime(cls, date_string: Never, format: Never) -> Never: ... # type: ignore[override]
def strptime(cls, date_string: Never, format: Never) -> Never: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def utcoffset(self) -> timedelta | None: ...
def tzname(self) -> str | None: ...
def dst(self) -> timedelta | None: ...
Expand Down Expand Up @@ -207,7 +209,7 @@ class Timestamp(datetime):
@overload
def __sub__(self, other: TimedeltaSeries) -> TimestampSeries: ...
@overload
def __sub__(
def __sub__( # pyright: ignore[reportIncompatibleMethodOverride]
self, other: npt.NDArray[np.timedelta64]
) -> npt.NDArray[np.datetime64]: ...
@overload
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/arraylike.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ from pandas._libs.ops_dispatch import (
)

class OpsMixin:
def __eq__(self, other: object) -> Self: ... # type: ignore[override]
def __ne__(self, other: object) -> Self: ... # type: ignore[override]
def __eq__(self, other: object) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def __ne__(self, other: object) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def __lt__(self, other: Any) -> Self: ...
def __le__(self, other: Any) -> Self: ...
def __gt__(self, other: Any) -> Self: ...
Expand Down
5 changes: 2 additions & 3 deletions pandas-stubs/core/arrays/boolean.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import ClassVar

import numpy as np
from pandas.core.arrays.masked import BaseMaskedArray as BaseMaskedArray

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

class BooleanDtype(ExtensionDtype):
na_value: ClassVar[NAType]
@property
def na_value(self) -> NAType: ...
@classmethod
def construct_array_type(cls) -> type_t[BooleanArray]: ...

Expand Down
9 changes: 3 additions & 6 deletions pandas-stubs/core/arrays/datetimelike.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ from pandas.core.arrays.base import (
ExtensionArray,
ExtensionOpsMixin,
)
from typing_extensions import Self

from pandas._libs import (
NaT as NaT,
NaTType as NaTType,
)
from pandas._typing import TakeIndexer

class DatelikeOps:
def strftime(self, date_format): ...
Expand All @@ -38,13 +36,12 @@ class DatetimeLikeArrayMixin(ExtensionOpsMixin, ExtensionArray):
def size(self) -> int: ...
def __len__(self) -> int: ...
def __getitem__(self, key): ...
def __setitem__(self, key: int | Sequence[int] | Sequence[bool] | slice, value) -> None: ... # type: ignore[override]
def __setitem__( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
self, key: int | Sequence[int] | Sequence[bool] | slice, value
) -> None: ...
def astype(self, dtype, copy: bool = ...): ...
def view(self, dtype=...): ...
def unique(self): ...
def take(
self: Self, indices: TakeIndexer, *, allow_fill: bool = ..., fill_value=...
) -> Self: ...
def copy(self): ...
def shift(self, periods: int = ..., fill_value=..., axis: int = ...): ...
def searchsorted(self, value, side: str = ..., sorter=...): ...
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/arrays/datetimes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DatetimeArray(DatetimeLikeArrayMixin, TimelikeOps, DatelikeOps):
def __init__(self, values, dtype=..., freq=..., copy: bool = ...) -> None: ...
# ignore in dtype() is from the pandas source
@property
def dtype(self) -> np.dtype | DatetimeTZDtype: ... # type: ignore[override]
def dtype(self) -> np.dtype | DatetimeTZDtype: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
@property
def tz(self): ...
@tz.setter
Expand Down
3 changes: 2 additions & 1 deletion pandas-stubs/core/arrays/integer.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class _IntegerDtype(ExtensionDtype):
def construct_array_type(cls) -> type[IntegerArray]: ...

class IntegerArray(BaseMaskedArray):
def dtype(self): ...
@property
def dtype(self) -> _IntegerDtype: ...
def __init__(self, values, mask, copy: bool = ...) -> None: ...
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): ...
def __setitem__(self, key, value) -> None: ...
Expand Down
3 changes: 1 addition & 2 deletions pandas-stubs/core/arrays/interval.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ from pandas._typing import (
)

class IntervalArray(IntervalMixin, ExtensionArray):
ndim: int = ...
can_hold_na: bool = ...
def __new__(
cls, data, closed=..., dtype=..., copy: bool = ..., verify_integrity: bool = ...
Expand Down Expand Up @@ -50,7 +49,7 @@ class IntervalArray(IntervalMixin, ExtensionArray):
@property
def size(self) -> int: ...
def shift(self, periods: int = ..., fill_value: object = ...) -> IntervalArray: ...
def take( # type: ignore[override]
def take( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
self: Self,
indices: TakeIndexer,
*,
Expand Down
4 changes: 0 additions & 4 deletions pandas-stubs/core/arrays/masked.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ from pandas.core.arrays import (

from pandas._typing import (
Scalar,
TakeIndexer,
npt,
)

Expand All @@ -27,8 +26,5 @@ class BaseMaskedArray(ExtensionArray, ExtensionOpsMixin):
def isna(self): ...
@property
def nbytes(self) -> int: ...
def take(
self, indexer: TakeIndexer, allow_fill: bool = ..., fill_value=...
) -> BaseMaskedArray: ...
def copy(self): ...
def value_counts(self, dropna: bool = ...): ...
8 changes: 5 additions & 3 deletions pandas-stubs/core/arrays/period.pyi
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
from collections.abc import Sequence

import numpy as np
from pandas import PeriodDtype
from pandas.core.arrays.datetimelike import (
DatelikeOps,
DatetimeLikeArrayMixin,
)

from pandas._libs.tslibs import Timestamp
from pandas._libs.tslibs.period import Period as Period
from pandas._libs.tslibs.period import Period

from pandas.tseries.offsets import Tick as Tick
from pandas.tseries.offsets import Tick

class PeriodArray(DatetimeLikeArrayMixin, DatelikeOps):
__array_priority__: int = ...
def __init__(self, values, freq=..., dtype=..., copy: bool = ...) -> None: ...
def dtype(self): ...
@property
def dtype(self) -> PeriodDtype: ...
def __array__(self, dtype=...) -> np.ndarray: ...
def __arrow_array__(self, type=...): ...
year: int = ...
Expand Down
9 changes: 0 additions & 9 deletions pandas-stubs/core/arrays/sparse/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ from pandas.core.arrays import (
ExtensionOpsMixin,
)

from pandas._typing import TakeIndexer

class SparseArray(ExtensionArray, ExtensionOpsMixin):
def __init__(
self,
Expand Down Expand Up @@ -43,15 +41,8 @@ class SparseArray(ExtensionArray, ExtensionOpsMixin):
def fillna(self, value=..., method=..., limit=...): ...
def shift(self, periods: int = ..., fill_value=...): ...
def unique(self): ...
def factorize(
self, na_sentinel: int = ..., use_na_sentinel: bool = ...
) -> tuple[np.ndarray, SparseArray]: ...
def value_counts(self, dropna: bool = ...): ...
def __getitem__(self, key): ...
def take(
self, indices: TakeIndexer, *, allow_fill: bool = ..., fill_value=...
) -> SparseArray: ...
def searchsorted(self, v, side: str = ..., sorter=...): ...
def copy(self): ...
def astype(self, dtype=..., copy: bool = ...): ...
def map(self, mapper): ...
Expand Down
4 changes: 0 additions & 4 deletions pandas-stubs/core/computation/pytables.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,18 @@ class FilterBinOp(BinOp):
filter: tuple[Any, Any, Index] | None = ...
def invert(self): ...
def format(self): ...
def evaluate(self): ...
def generate_filter_op(self, invert: bool = ...): ...

class JointFilterBinOp(FilterBinOp):
def format(self) -> None: ...
def evaluate(self): ...

class ConditionBinOp(BinOp):
def invert(self) -> None: ...
def format(self): ...
condition = ...
def evaluate(self): ...

class JointConditionBinOp(ConditionBinOp):
condition = ...
def evaluate(self): ...

class UnaryOp(ops.UnaryOp):
def prune(self, klass): ...
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/generic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ _bool = bool
_str = str

class NDFrame(indexing.IndexingMixin):
__hash__: ClassVar[None] # type: ignore[assignment]
__hash__: ClassVar[None] # type: ignore[assignment] # pyright: ignore[reportIncompatibleMethodOverride]

def set_flags(
self,
Expand Down
14 changes: 7 additions & 7 deletions pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class Index(IndexOpsMixin[S1]):
def is_mixed(self) -> bool: ...
def holds_integer(self): ...
@property
def inferred_type(self): ...
def inferred_type(self) -> _str: ...
def __reduce__(self): ...
@property
def hasnans(self) -> bool: ...
Expand Down Expand Up @@ -412,13 +412,13 @@ class Index(IndexOpsMixin[S1]):
@property
def shape(self) -> tuple[int, ...]: ...
# Extra methods from old stubs
def __eq__(self, other: object) -> np_ndarray_bool: ... # type: ignore[override]
def __eq__(self, other: object) -> np_ndarray_bool: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def __iter__(self) -> Iterator[S1]: ...
def __ne__(self, other: object) -> np_ndarray_bool: ... # type: ignore[override]
def __le__(self, other: Self | S1) -> np_ndarray_bool: ... # type: ignore[override]
def __ge__(self, other: Self | S1) -> np_ndarray_bool: ... # type: ignore[override]
def __lt__(self, other: Self | S1) -> np_ndarray_bool: ... # type: ignore[override]
def __gt__(self, other: Self | S1) -> np_ndarray_bool: ... # type: ignore[override]
def __ne__(self, other: object) -> np_ndarray_bool: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def __le__(self, other: Self | S1) -> np_ndarray_bool: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def __ge__(self, other: Self | S1) -> np_ndarray_bool: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def __lt__(self, other: Self | S1) -> np_ndarray_bool: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def __gt__(self, other: Self | S1) -> np_ndarray_bool: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
# overwrite inherited methods from OpsMixin
@overload
def __mul__( # type: ignore[misc]
Expand Down
3 changes: 0 additions & 3 deletions pandas-stubs/core/indexes/category.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ class CategoricalIndex(ExtensionIndex[S1], accessor.PandasDelegate):
def is_monotonic_decreasing(self) -> bool: ...
def unique(self, level=...): ...
def duplicated(self, keep: Literal["first", "last", False] = ...): ...
def get_loc(self, key): ...
def get_value(self, seriesArrayLike, key): ...
def where(self, cond, other=...): ...
def reindex(self, target, method=..., level=..., limit=..., tolerance=...): ...
def get_indexer(self, target, method=..., limit=..., tolerance=...): ...
def get_indexer_non_unique(self, target): ...
def take_nd(self, *args, **kwargs): ...
def map(self, mapper): ...
def delete(self, loc): ...
def insert(self, loc, item): ...
2 changes: 1 addition & 1 deletion pandas-stubs/core/indexes/datetimelike.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DatetimeIndexOpsMixin(ExtensionIndex[S1]):
def argmin(self, axis=..., skipna: bool = ..., *args, **kwargs): ...
def max(self, axis=..., skipna: bool = ..., *args, **kwargs): ...
def argmax(self, axis=..., skipna: bool = ..., *args, **kwargs): ...
def __rsub__( # type: ignore[override]
def __rsub__( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
self, other: DatetimeIndexOpsMixin
) -> TimedeltaIndex: ...

Expand Down
6 changes: 1 addition & 5 deletions pandas-stubs/core/indexes/datetimes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,11 @@ class DatetimeIndex(DatetimeTimedeltaMixin[Timestamp], DatetimeIndexProperties):
def __sub__(self, other: Timedelta | TimedeltaIndex) -> DatetimeIndex: ...
@overload
def __sub__(self, other: Timestamp | DatetimeIndex) -> TimedeltaIndex: ...
# overload needed because Index.to_series() and DatetimeIndex.to_series() have
# different arguments
def to_series(self, keep_tz=..., index=..., name=...) -> TimestampSeries: ... # type: ignore[override]
def to_series(self, index=..., name=...) -> TimestampSeries: ...
def snap(self, freq: str = ...): ...
def get_value(self, series, key): ...
def get_loc(self, key, tolerance=...): ...
def slice_indexer(self, start=..., end=..., step=...): ...
def searchsorted(self, value, side: str = ..., sorter=...): ...
def is_type_compatible(self, typ) -> bool: ...
@property
def inferred_type(self) -> str: ...
def insert(self, loc, item): ...
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/indexes/frozen.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class FrozenList(list):
def __eq__(self, other) -> bool: ...
def __mul__(self, other): ...
def __reduce__(self): ...
def __hash__(self) -> int: ... # type: ignore[override]
def __hash__(self) -> int: ... # type: ignore[override] # pyright: ignore[reportIncompatibleVariableOverride]
12 changes: 9 additions & 3 deletions pandas-stubs/core/indexes/interval.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ class IntervalIndex(ExtensionIndex[IntervalT], IntervalMixin):
| np_ndarray_bool,
) -> IntervalIndex[IntervalT]: ...
@overload
def __getitem__(self, idx: int) -> IntervalT: ...
def __getitem__( # pyright: ignore[reportIncompatibleMethodOverride]
self, idx: int
) -> IntervalT: ...
@property
def is_all_dates(self) -> bool: ...
@overload # type: ignore[override]
Expand Down Expand Up @@ -291,13 +293,17 @@ class IntervalIndex(ExtensionIndex[IntervalT], IntervalMixin):
@overload
def __eq__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ... # type: ignore[misc]
@overload
def __eq__(self, other: object) -> Literal[False]: ...
def __eq__( # pyright: ignore[reportIncompatibleMethodOverride]
self, other: object
) -> Literal[False]: ...
@overload # type: ignore[override]
def __ne__(self, other: IntervalT | IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
@overload
def __ne__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ... # type: ignore[misc]
@overload
def __ne__(self, other: object) -> Literal[True]: ...
def __ne__( # pyright: ignore[reportIncompatibleMethodOverride]
self, other: object
) -> Literal[True]: ...

# misc here because int and float overlap but interval has distinct types
# int gets hit first and so the correct type is returned
Expand Down
Loading