Skip to content

Commit 3e9c06e

Browse files
committed
fix: Never
1 parent c4b218e commit 3e9c06e

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

tests/series/arithmetic/test_add.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import numpy as np
22
from numpy import typing as npt # noqa: F401
33
import pandas as pd
4-
import pytest
54
from typing_extensions import (
65
Never,
7-
assert_never,
86
assert_type,
97
)
108

@@ -148,7 +146,9 @@ def test_add_str_py_str() -> None:
148146
if TYPE_CHECKING_INVALID_USAGE:
149147
assert_type(left_i + s, Never)
150148
assert_type(s + left_i, Never)
151-
with pytest.raises(AssertionError):
152-
assert_never(left_i.add(s))
153-
with pytest.raises(AssertionError):
154-
assert_never(left_i.radd(s))
149+
150+
def _type_checking_enabler_0() -> None: # pyright: ignore[reportUnusedFunction]
151+
assert_type(left_i.add(s), Never)
152+
153+
def _type_checking_enabler_1() -> None: # pyright: ignore[reportUnusedFunction]
154+
assert_type(left_i.radd(s), Never)

tests/series/arithmetic/test_sub.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
import numpy as np
88
from numpy import typing as npt # noqa: F401
99
import pandas as pd
10-
import pytest
1110
from typing_extensions import (
1211
Never,
13-
assert_never,
1412
assert_type,
1513
)
1614

@@ -181,6 +179,7 @@ def test_sub_ts_numpy_datetime() -> None:
181179
a = np.array([s + np.timedelta64(m, "m") for m in range(3)], np.datetime64)
182180

183181
if TYPE_CHECKING_INVALID_USAGE:
182+
# We would like to have _1, _3, _5 and _7 below as invalid, but numpy.ndarray.__rsub__ overrides our efforts
184183
_0 = left_ts - s # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
185184
# _1 = left_ts - a
186185
_2 = left_td - s # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
@@ -221,20 +220,24 @@ def test_sub_ts_pd_datetime() -> None:
221220
assert_type(a - left_td, Never)
222221

223222
left_ts.sub(s) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]
224-
with pytest.raises(AssertionError):
225-
assert_never(left_ts.sub(a))
223+
224+
def _type_checking_enabler_0() -> None: # pyright: ignore[reportUnusedFunction]
225+
assert_type(left_ts.sub(a), Never)
226226

227227
left_td.sub(s) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]
228-
with pytest.raises(AssertionError):
229-
assert_never(left_td.sub(a))
228+
229+
def _type_checking_enabler_1() -> None: # pyright: ignore[reportUnusedFunction]
230+
assert_type(left_td.sub(a), Never)
230231

231232
left_ts.rsub(s) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]
232-
with pytest.raises(AssertionError):
233-
assert_never(left_ts.rsub(a))
233+
234+
def _type_checking_enabler_2() -> None: # pyright: ignore[reportUnusedFunction]
235+
assert_type(left_ts.rsub(a), Never)
234236

235237
left_td.rsub(s) # type: ignore[arg-type] # pyright: ignore[reportArgumentType,reportCallIssue]
236-
with pytest.raises(AssertionError):
237-
assert_never(left_td.rsub(a))
238+
239+
def _type_checking_enabler_3() -> None: # pyright: ignore[reportUnusedFunction]
240+
assert_type(left_td.rsub(a), Never)
238241

239242

240243
def test_sub_str_py_str() -> None:

0 commit comments

Comments
 (0)