Skip to content

Commit

Permalink
TYP: pandas.core.series annotations from pandas-stubs (#47926)
Browse files Browse the repository at this point in the history
* TYP: pandas.core.series annotations from pandas-stubs

* and DataFrame

* more compatibility with pandas-stub tests

* mypy address line-off-by-one (merge?) issue
  • Loading branch information
twoertwein committed Aug 15, 2022
1 parent 152c4da commit 50c2af1
Show file tree
Hide file tree
Showing 12 changed files with 507 additions and 494 deletions.
4 changes: 2 additions & 2 deletions pandas/_testing/asserters.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def assert_series_equal(
left,
right,
check_dtype: bool | Literal["equiv"] = True,
check_index_type="equiv",
check_index_type: bool | Literal["equiv"] = "equiv",
check_series_type=True,
check_less_precise: bool | int | NoDefault = no_default,
check_names=True,
Expand Down Expand Up @@ -1134,7 +1134,7 @@ def assert_frame_equal(
left,
right,
check_dtype: bool | Literal["equiv"] = True,
check_index_type="equiv",
check_index_type: bool | Literal["equiv"] = "equiv",
check_column_type="equiv",
check_frame_type=True,
check_less_precise=no_default,
Expand Down
4 changes: 2 additions & 2 deletions pandas/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
Timedelta,
Timestamp,
)
from pandas._libs.tslibs import BaseOffset

from pandas.core.dtypes.dtypes import ExtensionDtype

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

from pandas.io.formats.format import EngFormatter
from pandas.tseries.offsets import DateOffset

# numpy compatible types
NumpyValueArrayLike = Union[npt._ScalarLike_co, npt.ArrayLike]
Expand Down Expand Up @@ -113,7 +113,7 @@
Suffixes = Tuple[Optional[str], Optional[str]]
Ordered = Optional[bool]
JSONSerializable = Optional[Union[PythonScalar, List, Dict]]
Frequency = Union[str, "DateOffset"]
Frequency = Union[str, "BaseOffset"]
Axes = Union[AnyArrayLike, List, range]

RandomState = Union[
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ def equals(self, other: object) -> bool:
equal_na = self.isna() & other.isna() # type: ignore[operator]
return bool((equal_values | equal_na).all())

def isin(self, values) -> np.ndarray:
def isin(self, values) -> npt.NDArray[np.bool_]:
"""
Pointwise comparison for set containment in the given values.
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ def contains(self, other):
other < self._right if self.open_right else other <= self._right
)

def isin(self, values) -> np.ndarray:
def isin(self, values) -> npt.NDArray[np.bool_]:
if not hasattr(values, "dtype"):
values = np.array(values)
values = extract_array(values, extract_numpy=True)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/string_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _maybe_convert_setitem_value(self, value):
raise ValueError("Scalar must be NA or str")
return value

def isin(self, values):
def isin(self, values) -> npt.NDArray[np.bool_]:
if pa_version_under2p0:
fallback_performancewarning(version="2")
return super().isin(values)
Expand Down
Loading

0 comments on commit 50c2af1

Please sign in to comment.