Skip to content

Commit 002406e

Browse files
twoertweinnoatamir
authored andcommitted
TYP: pandas.core.series annotations from pandas-stubs (pandas-dev#47926)
* TYP: pandas.core.series annotations from pandas-stubs * and DataFrame * more compatibility with pandas-stub tests * mypy address line-off-by-one (merge?) issue
1 parent 05baac8 commit 002406e

File tree

12 files changed

+507
-494
lines changed

12 files changed

+507
-494
lines changed

pandas/_testing/asserters.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def assert_series_equal(
866866
left,
867867
right,
868868
check_dtype: bool | Literal["equiv"] = True,
869-
check_index_type="equiv",
869+
check_index_type: bool | Literal["equiv"] = "equiv",
870870
check_series_type=True,
871871
check_less_precise: bool | int | NoDefault = no_default,
872872
check_names=True,
@@ -1134,7 +1134,7 @@ def assert_frame_equal(
11341134
left,
11351135
right,
11361136
check_dtype: bool | Literal["equiv"] = True,
1137-
check_index_type="equiv",
1137+
check_index_type: bool | Literal["equiv"] = "equiv",
11381138
check_column_type="equiv",
11391139
check_frame_type=True,
11401140
check_less_precise=no_default,

pandas/_typing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
Timedelta,
4040
Timestamp,
4141
)
42+
from pandas._libs.tslibs import BaseOffset
4243

4344
from pandas.core.dtypes.dtypes import ExtensionDtype
4445

@@ -63,7 +64,6 @@
6364
from pandas.core.window.rolling import BaseWindow
6465

6566
from pandas.io.formats.format import EngFormatter
66-
from pandas.tseries.offsets import DateOffset
6767

6868
# numpy compatible types
6969
NumpyValueArrayLike = Union[npt._ScalarLike_co, npt.ArrayLike]
@@ -113,7 +113,7 @@
113113
Suffixes = Tuple[Optional[str], Optional[str]]
114114
Ordered = Optional[bool]
115115
JSONSerializable = Optional[Union[PythonScalar, List, Dict]]
116-
Frequency = Union[str, "DateOffset"]
116+
Frequency = Union[str, "BaseOffset"]
117117
Axes = Union[AnyArrayLike, List, range]
118118

119119
RandomState = Union[

pandas/core/arrays/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ def equals(self, other: object) -> bool:
985985
equal_na = self.isna() & other.isna() # type: ignore[operator]
986986
return bool((equal_values | equal_na).all())
987987

988-
def isin(self, values) -> np.ndarray:
988+
def isin(self, values) -> npt.NDArray[np.bool_]:
989989
"""
990990
Pointwise comparison for set containment in the given values.
991991

pandas/core/arrays/interval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,7 @@ def contains(self, other):
17381738
other < self._right if self.open_right else other <= self._right
17391739
)
17401740

1741-
def isin(self, values) -> np.ndarray:
1741+
def isin(self, values) -> npt.NDArray[np.bool_]:
17421742
if not hasattr(values, "dtype"):
17431743
values = np.array(values)
17441744
values = extract_array(values, extract_numpy=True)

pandas/core/arrays/string_arrow.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def _maybe_convert_setitem_value(self, value):
202202
raise ValueError("Scalar must be NA or str")
203203
return value
204204

205-
def isin(self, values):
205+
def isin(self, values) -> npt.NDArray[np.bool_]:
206206
if pa_version_under2p0:
207207
fallback_performancewarning(version="2")
208208
return super().isin(values)

0 commit comments

Comments
 (0)