Skip to content

Remove use of Never #506

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

Merged
merged 1 commit into from
Jan 14, 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
33 changes: 14 additions & 19 deletions pandas-stubs/core/indexes/interval.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ from pandas.core.series import (
TimedeltaSeries,
TimestampSeries,
)
from typing_extensions import (
Never,
TypeAlias,
)
from typing_extensions import TypeAlias

from pandas._libs.interval import (
Interval as Interval,
Expand Down Expand Up @@ -260,31 +257,29 @@ class IntervalIndex(IntervalMixin, ExtensionIndex, Generic[IntervalT]):
# override is due to additional types for comparison
# misc is due to overlap with object below
@overload # type: ignore[override]
def __gt__( # type: ignore[misc]
def __gt__(
self, other: IntervalT | IntervalIndex[IntervalT]
) -> np_ndarray_bool: ...
@overload
def __gt__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ... # type: ignore[misc]
@overload
def __gt__(self, other: object) -> Never: ...
def __gt__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ...
@overload # type: ignore[override]
def __ge__(self, other: IntervalT | IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc]
@overload
def __ge__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ... # type: ignore[misc]
def __ge__(
self, other: IntervalT | IntervalIndex[IntervalT]
) -> np_ndarray_bool: ...
@overload
def __ge__(self, other: object) -> Never: ...
def __ge__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ...
@overload # type: ignore[override]
def __le__(self, other: IntervalT | IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc]
@overload
def __le__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ... # type: ignore[misc]
def __le__(
self, other: IntervalT | IntervalIndex[IntervalT]
) -> np_ndarray_bool: ...
@overload
def __le__(self, other: object) -> Never: ...
def __le__(self, other: pd.Series[IntervalT]) -> pd.Series[bool]: ...
@overload # type: ignore[override]
def __lt__(self, other: IntervalT | IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc]
def __lt__(
self, other: IntervalT | IntervalIndex[IntervalT]
) -> np_ndarray_bool: ...
@overload
def __lt__(self, other: pd.Series[IntervalT]) -> bool: ... # type: ignore[misc]
@overload
def __lt__(self, other: object) -> Never: ...
@overload # type: ignore[override]
def __eq__(self, other: IntervalT | IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc]
@overload
Expand Down
18 changes: 6 additions & 12 deletions pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ from pandas.core.window.rolling import (
Rolling,
Window,
)
from typing_extensions import (
Never,
TypeAlias,
)
from typing_extensions import TypeAlias
import xarray as xr

from pandas._libs.interval import Interval
Expand Down Expand Up @@ -1814,8 +1811,8 @@ class TimestampSeries(Series[Timestamp]):
@property
def dt(self) -> TimestampProperties: ... # type: ignore[override]
def __add__(self, other: TimedeltaSeries | np.timedelta64) -> TimestampSeries: ... # type: ignore[override]
def __mul__(self, other: TimestampSeries | np.timedelta64 | TimedeltaSeries) -> Never: ... # type: ignore[override]
def __truediv__(self, other: TimestampSeries | np.timedelta64 | TimedeltaSeries) -> Never: ... # type: ignore[override]
def __mul__(self, other: int | float | Series[int] | Series[float] | Sequence[int | float]) -> TimestampSeries: ... # type: ignore[override]
def __truediv__(self, other: int | float | Series[int] | Series[float] | Sequence[int | float]) -> TimestampSeries: ... # type: ignore[override]
def mean( # type: ignore[override]
self,
axis: SeriesAxisType | None = ...,
Expand Down Expand Up @@ -1853,12 +1850,9 @@ class TimedeltaSeries(Series[Timedelta]):
@overload
def __add__(self, other: Timedelta | np.timedelta64) -> TimedeltaSeries: ...
def __radd__(self, other: Timestamp | TimestampSeries) -> TimestampSeries: ... # type: ignore[override]
@overload # type: ignore[override]
def __mul__(
self, other: TimestampSeries | np.timedelta64 | Timedelta | TimedeltaSeries
) -> Never: ...
@overload
def __mul__(self, other: num) -> TimedeltaSeries: ...
def __mul__( # type: ignore[override]
self, other: num | Sequence[num] | Series[int] | Series[float]
) -> TimedeltaSeries: ...
def __sub__( # type: ignore[override]
self, other: Timedelta | TimedeltaSeries | TimedeltaIndex | np.timedelta64
) -> TimedeltaSeries: ...
Expand Down
11 changes: 4 additions & 7 deletions tests/test_timefuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
import pandas as pd
from pandas.core.indexes.numeric import IntegerIndex
import pytz
from typing_extensions import (
Never,
assert_type,
)
from typing_extensions import assert_type

from pandas._libs import NaTType
from pandas._libs.tslibs import BaseOffset
Expand Down Expand Up @@ -1088,9 +1085,9 @@ def test_timedelta64_and_arithmatic_operator() -> None:
check(assert_type((s3 + td), "TimedeltaSeries"), pd.Series, pd.Timedelta)
check(assert_type((s3 / td), "pd.Series[float]"), pd.Series, float)
if TYPE_CHECKING_INVALID_USAGE:
assert_type((s1 * td), Never) # pyright: ignore[reportGeneralTypeIssues]
assert_type((s1 / td), Never) # pyright: ignore[reportGeneralTypeIssues]
assert_type((s3 * td), Never) # pyright: ignore[reportGeneralTypeIssues]
r1 = s1 * td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues]
r2 = s1 / td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues]
r3 = s3 * td # type: ignore[operator] # pyright: ignore[reportGeneralTypeIssues]


def test_timedeltaseries_add_timestampseries() -> None:
Expand Down