Skip to content

Commit b783f02

Browse files
committed
https://github.com/pandas-dev/pandas-stubs/pull/1479/files/d6592685321c6add64ff4bfd12c6984e5efa3d70#r2515222772
1 parent 62ceaee commit b783f02

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

pandas-stubs/core/resample.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class Resampler(BaseGroupBy[NDFrameT]):
9898
*,
9999
axis: Axis = ...,
100100
limit: int | None = ...,
101+
inplace: Literal[False] = False,
101102
limit_direction: Literal["forward", "backward", "both"] = ...,
102103
limit_area: Literal["inside", "outside"] | None = ...,
103104
**kwargs: Any,

tests/test_resampler.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Hashable,
33
Iterator,
44
)
5+
from typing import TypeAlias
56

67
import numpy as np
78
import pandas as pd
@@ -18,11 +19,17 @@
1819
from typing_extensions import assert_type
1920

2021
from tests import (
22+
PD_LTE_23,
2123
TYPE_CHECKING_INVALID_USAGE,
2224
check,
2325
pytest_warns_bounded,
2426
)
2527

28+
if not PD_LTE_23:
29+
from pandas.errors import Pandas4Warning # type: ignore[attr-defined] # pyright: ignore[reportAttributeAccessIssue,reportRedeclaration] # isort: skip
30+
else:
31+
Pandas4Warning: TypeAlias = FutureWarning # type: ignore[no-redef]
32+
2633
DR = date_range("1999-1-1", periods=365, freq="D")
2734
DF_ = DataFrame(np.random.standard_normal((365, 1)), index=DR)
2835
S = DF_.iloc[:, 0]
@@ -145,6 +152,21 @@ def test_interpolate() -> None:
145152
)
146153

147154

155+
# TODO: remove the whole test function when the warning and ValueError in pandas-dev/pandas#62847 are removed
156+
def test_interpolate_inplace() -> None:
157+
with pytest_warns_bounded(
158+
Pandas4Warning,
159+
"The 'inplace' keyword in DatetimeIndexResampler.interpolate is deprecated and will be removed in a future version. resample(...).interpolate is never inplace.",
160+
lower="2.99",
161+
):
162+
check(
163+
assert_type(DF.resample("ME").interpolate(inplace=False), DataFrame),
164+
DataFrame,
165+
)
166+
if TYPE_CHECKING_INVALID_USAGE:
167+
DF.resample("ME").interpolate(inplace=True) # type: ignore[call-arg] # pyright: ignore[reportArgumentType]
168+
169+
148170
def test_pipe() -> None:
149171
def f(val: "DatetimeIndexResampler[DataFrame]") -> DataFrame:
150172
assert isinstance(val, DatetimeIndexResampler)

0 commit comments

Comments
 (0)