Skip to content

Commit

Permalink
CI: fix nightly (#869)
Browse files Browse the repository at this point in the history
* CI: fix nightly

* remove ignores and address comment
  • Loading branch information
twoertwein authored Feb 13, 2024
1 parent a51279e commit 23b35e4
Show file tree
Hide file tree
Showing 15 changed files with 297 additions and 343 deletions.
2 changes: 1 addition & 1 deletion pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ SequenceIndexer: TypeAlias = slice | list[int] | np.ndarray
PositionalIndexer: TypeAlias = ScalarIndexer | SequenceIndexer
TakeIndexer: TypeAlias = Sequence[int] | Sequence[np.integer] | npt.NDArray[np.integer]

IgnoreRaiseCoerce: TypeAlias = Literal["ignore", "raise", "coerce"]
RaiseCoerce: TypeAlias = Literal["raise", "coerce"]

# Shared by functions such as drop and astype
IgnoreRaise: TypeAlias = Literal["ignore", "raise"]
Expand Down
6 changes: 3 additions & 3 deletions pandas-stubs/core/tools/datetimes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ from pandas._typing import (
AnyArrayLike,
DictConvertible,
IgnoreRaise,
IgnoreRaiseCoerce,
RaiseCoerce,
TimestampConvertibleTypes,
npt,
)
Expand Down Expand Up @@ -68,7 +68,7 @@ def to_datetime(
@overload
def to_datetime(
arg: Series | DictConvertible,
errors: IgnoreRaiseCoerce = ...,
errors: RaiseCoerce = ...,
dayfirst: bool = ...,
yearfirst: bool = ...,
utc: bool = ...,
Expand All @@ -91,7 +91,7 @@ def to_datetime(
| Index
| ExtensionArray
),
errors: IgnoreRaiseCoerce = ...,
errors: RaiseCoerce = ...,
dayfirst: bool = ...,
yearfirst: bool = ...,
utc: bool = ...,
Expand Down
6 changes: 3 additions & 3 deletions pandas-stubs/core/tools/numeric.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from typing_extensions import TypeAlias
from pandas._libs.lib import NoDefault
from pandas._typing import (
DtypeBackend,
IgnoreRaiseCoerce,
RaiseCoerce,
Scalar,
npt,
)
Expand All @@ -27,14 +27,14 @@ def to_numeric(
@overload
def to_numeric(
arg: list | tuple | np.ndarray,
errors: IgnoreRaiseCoerce = ...,
errors: RaiseCoerce = ...,
downcast: _Downcast = ...,
dtype_backend: DtypeBackend | NoDefault = ...,
) -> npt.NDArray: ...
@overload
def to_numeric(
arg: pd.Series,
errors: IgnoreRaiseCoerce = ...,
errors: RaiseCoerce = ...,
downcast: _Downcast = ...,
dtype_backend: DtypeBackend | NoDefault = ...,
) -> pd.Series: ...
8 changes: 4 additions & 4 deletions pandas-stubs/core/tools/timedeltas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ from pandas._libs.tslibs import Timedelta
from pandas._libs.tslibs.timedeltas import TimeDeltaUnitChoices
from pandas._typing import (
ArrayLike,
IgnoreRaiseCoerce,
RaiseCoerce,
)

@overload
def to_timedelta(
arg: str | float | timedelta,
unit: TimeDeltaUnitChoices | None = ...,
errors: IgnoreRaiseCoerce = ...,
errors: RaiseCoerce = ...,
) -> Timedelta: ...
@overload
def to_timedelta(
arg: Series,
unit: TimeDeltaUnitChoices | None = ...,
errors: IgnoreRaiseCoerce = ...,
errors: RaiseCoerce = ...,
) -> TimedeltaSeries: ...
@overload
def to_timedelta(
Expand All @@ -39,5 +39,5 @@ def to_timedelta(
| Index
),
unit: TimeDeltaUnitChoices | None = ...,
errors: IgnoreRaiseCoerce = ...,
errors: RaiseCoerce = ...,
) -> TimedeltaIndex: ...
10 changes: 0 additions & 10 deletions pandas-stubs/io/formats/style.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,6 @@ class Styler(StylerRenderer):
level: Level | list[Level] | None = ...,
**kwargs: Any,
) -> Styler: ...
def applymap_index(
self,
func: Callable[[Scalar], str],
axis: Axis = ...,
level: Level | list[Level] | None = ...,
**kwargs: Any,
) -> Styler: ...
def applymap(
self, func: Callable[[Scalar], str], subset: Subset | None = ..., **kwargs: Any
) -> Styler: ...
def set_table_attributes(self, attributes: str) -> Styler: ...
def export(self) -> StyleExportDict: ...
def use(self, styles: StyleExportDict) -> Styler: ...
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING
WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower()
PD_LTE_21 = Version(pd.__version__) < Version("2.1.999")
PD_LTE_22 = Version(pd.__version__) < Version("2.2.999")


def check(actual: T, klass: type, dtype: type | None = None, attr: str = "left") -> T:
Expand Down
15 changes: 10 additions & 5 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from pandas import errors
import pytest

from tests import WINDOWS
from tests import (
PD_LTE_22,
WINDOWS,
)


def test_abstract_method_error() -> None:
Expand Down Expand Up @@ -105,13 +108,15 @@ def test_specification_error() -> None:


def test_setting_with_copy_error() -> None:
with pytest.raises(errors.SettingWithCopyError):
raise errors.SettingWithCopyError()
if PD_LTE_22:
with pytest.raises(errors.SettingWithCopyError):
raise errors.SettingWithCopyError()


def test_setting_with_copy_warning() -> None:
with pytest.warns(errors.SettingWithCopyWarning):
warnings.warn("", errors.SettingWithCopyWarning)
if PD_LTE_22:
with pytest.warns(errors.SettingWithCopyWarning):
warnings.warn("", errors.SettingWithCopyWarning)


def test_numexpr_clobbering_error() -> None:
Expand Down
9 changes: 7 additions & 2 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from pandas._typing import Scalar

from tests import (
PD_LTE_22,
TYPE_CHECKING_INVALID_USAGE,
check,
pytest_warns_bounded,
Expand Down Expand Up @@ -2257,7 +2258,11 @@ def test_groupby_result() -> None:
index, value = next(iterator)
assert_type((index, value), tuple[tuple, pd.DataFrame])

check(assert_type(index, tuple), tuple, np.integer)
if PD_LTE_22:
check(assert_type(index, tuple), tuple, np.integer)
else:
check(assert_type(index, tuple), tuple, int)

check(assert_type(value, pd.DataFrame), pd.DataFrame)

iterator2 = df.groupby("a").__iter__()
Expand Down Expand Up @@ -2365,7 +2370,7 @@ def test_groupby_result_for_ambiguous_indexes() -> None:
with pytest_warns_bounded(
FutureWarning,
"The default of observed=False is deprecated",
lower="2.0.99",
upper="2.2.99",
):
categorical_index = pd.CategoricalIndex(df.a)
iterator2 = df.groupby(categorical_index).__iter__()
Expand Down
Loading

0 comments on commit 23b35e4

Please sign in to comment.