|
7 | 7 | import numpy as np
|
8 | 8 | from numpy import typing as npt # noqa: F401
|
9 | 9 | import pandas as pd
|
10 |
| -import pytest |
11 | 10 | from typing_extensions import (
|
12 | 11 | Never,
|
13 |
| - assert_never, |
14 | 12 | assert_type,
|
15 | 13 | )
|
16 | 14 |
|
@@ -181,6 +179,7 @@ def test_sub_ts_numpy_datetime() -> None:
|
181 | 179 | a = np.array([s + np.timedelta64(m, "m") for m in range(3)], np.datetime64)
|
182 | 180 |
|
183 | 181 | 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 |
184 | 183 | _0 = left_ts - s # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
|
185 | 184 | # _1 = left_ts - a
|
186 | 185 | _2 = left_td - s # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
|
@@ -221,20 +220,24 @@ def test_sub_ts_pd_datetime() -> None:
|
221 | 220 | assert_type(a - left_td, Never)
|
222 | 221 |
|
223 | 222 | 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) |
226 | 226 |
|
227 | 227 | 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) |
230 | 231 |
|
231 | 232 | 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) |
234 | 236 |
|
235 | 237 | 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) |
238 | 241 |
|
239 | 242 |
|
240 | 243 | def test_sub_str_py_str() -> None:
|
|
0 commit comments