Skip to content

Commit c8e3ab2

Browse files
committed
fix: pd.Series[bool] - pd.Series[bool]
1 parent 1e9b11d commit c8e3ab2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/series/arithmetic/bool/test_sub.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import cast
2+
13
import numpy as np
24
from numpy import typing as npt # noqa: F401
35
import pandas as pd
@@ -124,14 +126,15 @@ def test_sub_pd_series() -> None:
124126
f = pd.Series([1.0, 2.0, 3.0])
125127
c = pd.Series([1.1j, 2.2j, 4.1j])
126128

129+
# In the following two cases, mypy fails to recognise the second operand as pd.Series[bool]
127130
if TYPE_CHECKING_INVALID_USAGE:
128-
_ = left - b # pyright: ignore[reportOperatorIssue]
131+
_ = left - cast("pd.Series[bool]", b) # type: ignore[redundant-cast,operator] # pyright: ignore[reportUnnecessaryCast,reportOperatorIssue]
129132
check(assert_type(left - i, "pd.Series[int]"), pd.Series, np.integer)
130133
check(assert_type(left - f, "pd.Series[float]"), pd.Series, np.floating)
131134
check(assert_type(left - c, "pd.Series[complex]"), pd.Series, np.complexfloating)
132135

133136
if TYPE_CHECKING_INVALID_USAGE:
134-
_ = b - left # pyright: ignore[reportOperatorIssue]
137+
_ = b - cast("pd.Series[bool]", left) # type: ignore[redundant-cast,operator] # pyright: ignore[reportUnnecessaryCast,reportOperatorIssue]
135138
check(assert_type(i - left, "pd.Series[int]"), pd.Series, np.integer)
136139
check(assert_type(f - left, "pd.Series[float]"), pd.Series, np.floating)
137140
check(assert_type(c - left, "pd.Series[complex]"), pd.Series, np.complexfloating)

0 commit comments

Comments
 (0)