Skip to content

Commit 072997b

Browse files
authored
Fix nightly (#904)
* CI nightly * pre-commit * remove deprecated arguments * remove deprecated Timedelta units * remove list from unique * remove more undocumented/deprecated units
1 parent b30d777 commit 072997b

15 files changed

+125
-213
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ ci:
33
autofix_prs: false
44
repos:
55
- repo: https://github.com/python/black
6-
rev: 24.2.0
6+
rev: 24.3.0
77
hooks:
88
- id: black
99
- repo: https://github.com/PyCQA/isort
1010
rev: 5.13.2
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.3.0
14+
rev: v0.3.5
1515
hooks:
1616
- id: ruff
1717
args: [

pandas-stubs/_libs/tslibs/timedeltas.pyi

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ class Components(NamedTuple):
4848
# This should be kept consistent with the keys in the dict timedelta_abbrevs
4949
# in pandas/_libs/tslibs/timedeltas.pyx
5050
TimeDeltaUnitChoices: TypeAlias = Literal[
51-
"H",
52-
"T",
53-
"S",
54-
"L",
55-
"U",
56-
"N",
5751
"W",
5852
"w",
5953
"D",
@@ -68,7 +62,6 @@ TimeDeltaUnitChoices: TypeAlias = Literal[
6862
"minute",
6963
"min",
7064
"minutes",
71-
"t",
7265
"s",
7366
"seconds",
7467
"sec",
@@ -78,20 +71,17 @@ TimeDeltaUnitChoices: TypeAlias = Literal[
7871
"millisecond",
7972
"milli",
8073
"millis",
81-
"l",
8274
"us",
8375
"microseconds",
8476
"microsecond",
8577
"µs",
8678
"micro",
8779
"micros",
88-
"u",
8980
"ns",
9081
"nanoseconds",
9182
"nano",
9283
"nanos",
9384
"nanosecond",
94-
"n",
9585
]
9686

9787
UnitChoices: TypeAlias = (

pandas-stubs/core/algorithms.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from collections.abc import Sequence
21
from typing import (
32
Literal,
43
overload,
@@ -37,12 +36,12 @@ def unique(values: Categorical) -> Categorical: ...
3736
@overload
3837
def unique(values: Series) -> np.ndarray | ExtensionArray: ...
3938
@overload
40-
def unique(values: np.ndarray | list) -> np.ndarray: ...
39+
def unique(values: np.ndarray) -> np.ndarray: ...
4140
@overload
4241
def unique(values: ExtensionArray) -> ExtensionArray: ...
4342
@overload
4443
def factorize(
45-
values: Sequence | np.recarray,
44+
values: np.ndarray,
4645
sort: bool = ...,
4746
use_na_sentinel: bool = ...,
4847
size_hint: int | None = ...,

pandas-stubs/core/indexes/timedeltas.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class TimedeltaIndex(DatetimeTimedeltaMixin[Timedelta], TimedeltaIndexProperties
4040
| list[str]
4141
| Sequence[dt.timedelta | Timedelta | np.timedelta64 | float]
4242
) = ...,
43-
unit: Literal["D", "h", "m", "s", "ms", "us", "ns"] = ...,
4443
freq: str | BaseOffset = ...,
4544
closed: object = ...,
4645
dtype: Literal["<m8[ns]"] = ...,

pandas-stubs/core/reshape/merge.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def merge(
3232
suffixes: (
3333
list[str | None] | tuple[str, str] | tuple[None, str] | tuple[str, None]
3434
) = ...,
35-
copy: bool = ...,
3635
indicator: bool | str = ...,
3736
validate: ValidationOptions = ...,
3837
) -> DataFrame: ...

tests/test_frame.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -983,12 +983,15 @@ def test_types_groupby() -> None:
983983
with pytest_warns_bounded(
984984
FutureWarning,
985985
"(The provided callable <built-in function sum> is currently using|The behavior of DataFrame.sum with)",
986+
upper="2.2.99",
986987
):
987988
with pytest_warns_bounded(
988989
DeprecationWarning,
989990
"DataFrameGroupBy.apply operated on the grouping columns",
991+
upper="2.2.99",
990992
):
991-
df7: pd.DataFrame = df.groupby(by="col1").apply(sum)
993+
if PD_LTE_22:
994+
df7: pd.DataFrame = df.groupby(by="col1").apply(sum)
992995
df8: pd.DataFrame = df.groupby("col1").transform("sum")
993996
s1: pd.Series = df.set_index("col1")["col2"]
994997
s2: pd.Series = s1.groupby("col1").transform("sum")
@@ -1033,7 +1036,7 @@ def wrapped_min(x: Any) -> Any:
10331036
with pytest_warns_bounded(
10341037
FutureWarning,
10351038
r"The provided callable <built-in function (min|max)> is currently using",
1036-
lower="2.0.99",
1039+
upper="2.2.99",
10371040
):
10381041
check(assert_type(df.groupby("col1")["col3"].agg(min), pd.Series), pd.Series)
10391042
check(
@@ -1182,7 +1185,7 @@ def test_types_window() -> None:
11821185
with pytest_warns_bounded(
11831186
FutureWarning,
11841187
r"The provided callable <built-in function (min|max)> is currently using",
1185-
lower="2.0.99",
1188+
upper="2.2.99",
11861189
):
11871190
check(
11881191
assert_type(df.rolling(2).agg(max), pd.DataFrame),
@@ -1282,7 +1285,7 @@ def test_types_agg() -> None:
12821285
with pytest_warns_bounded(
12831286
FutureWarning,
12841287
r"The provided callable <(built-in function (min|max|mean)|function mean at 0x\w+)> is currently using",
1285-
lower="2.0.99",
1288+
upper="2.2.99",
12861289
):
12871290
check(assert_type(df.agg(min), pd.Series), pd.Series)
12881291
check(assert_type(df.agg([min, max]), pd.DataFrame), pd.DataFrame)
@@ -1309,7 +1312,7 @@ def test_types_aggregate() -> None:
13091312
with pytest_warns_bounded(
13101313
FutureWarning,
13111314
r"The provided callable <built-in function (min|max)> is currently using",
1312-
lower="2.0.99",
1315+
upper="2.2.99",
13131316
):
13141317
check(assert_type(df.aggregate(min), pd.Series), pd.Series)
13151318
check(assert_type(df.aggregate([min, max]), pd.DataFrame), pd.DataFrame)
@@ -2222,7 +2225,7 @@ def test_frame_stack() -> None:
22222225
with pytest_warns_bounded(
22232226
FutureWarning,
22242227
"The previous implementation of stack is deprecated",
2225-
lower="2.1.99",
2228+
upper="2.2.99",
22262229
):
22272230
check(
22282231
assert_type(
@@ -2593,23 +2596,22 @@ def test_resample() -> None:
25932596
# GH 181
25942597
N = 10
25952598
x = [x for x in range(N)]
2596-
with pytest_warns_bounded(FutureWarning, "'T' is deprecated", lower="2.1.99"):
2597-
index = pd.date_range("1/1/2000", periods=N, freq="T")
2598-
x = [x for x in range(N)]
2599-
df = pd.DataFrame({"a": x, "b": x, "c": x}, index=index)
2600-
check(assert_type(df.resample("2T").std(), pd.DataFrame), pd.DataFrame)
2601-
check(assert_type(df.resample("2T").var(), pd.DataFrame), pd.DataFrame)
2602-
check(assert_type(df.resample("2T").quantile(), pd.DataFrame), pd.DataFrame)
2603-
check(assert_type(df.resample("2T").sum(), pd.DataFrame), pd.DataFrame)
2604-
check(assert_type(df.resample("2T").prod(), pd.DataFrame), pd.DataFrame)
2605-
check(assert_type(df.resample("2T").min(), pd.DataFrame), pd.DataFrame)
2606-
check(assert_type(df.resample("2T").max(), pd.DataFrame), pd.DataFrame)
2607-
check(assert_type(df.resample("2T").first(), pd.DataFrame), pd.DataFrame)
2608-
check(assert_type(df.resample("2T").last(), pd.DataFrame), pd.DataFrame)
2609-
check(assert_type(df.resample("2T").mean(), pd.DataFrame), pd.DataFrame)
2610-
check(assert_type(df.resample("2T").sem(), pd.DataFrame), pd.DataFrame)
2611-
check(assert_type(df.resample("2T").median(), pd.DataFrame), pd.DataFrame)
2612-
check(assert_type(df.resample("2T").ohlc(), pd.DataFrame), pd.DataFrame)
2599+
index = pd.date_range("1/1/2000", periods=N, freq="min")
2600+
x = [x for x in range(N)]
2601+
df = pd.DataFrame({"a": x, "b": x, "c": x}, index=index)
2602+
check(assert_type(df.resample("2min").std(), pd.DataFrame), pd.DataFrame)
2603+
check(assert_type(df.resample("2min").var(), pd.DataFrame), pd.DataFrame)
2604+
check(assert_type(df.resample("2min").quantile(), pd.DataFrame), pd.DataFrame)
2605+
check(assert_type(df.resample("2min").sum(), pd.DataFrame), pd.DataFrame)
2606+
check(assert_type(df.resample("2min").prod(), pd.DataFrame), pd.DataFrame)
2607+
check(assert_type(df.resample("2min").min(), pd.DataFrame), pd.DataFrame)
2608+
check(assert_type(df.resample("2min").max(), pd.DataFrame), pd.DataFrame)
2609+
check(assert_type(df.resample("2min").first(), pd.DataFrame), pd.DataFrame)
2610+
check(assert_type(df.resample("2min").last(), pd.DataFrame), pd.DataFrame)
2611+
check(assert_type(df.resample("2min").mean(), pd.DataFrame), pd.DataFrame)
2612+
check(assert_type(df.resample("2min").sem(), pd.DataFrame), pd.DataFrame)
2613+
check(assert_type(df.resample("2min").median(), pd.DataFrame), pd.DataFrame)
2614+
check(assert_type(df.resample("2min").ohlc(), pd.DataFrame), pd.DataFrame)
26132615

26142616

26152617
def test_loc_set() -> None:
@@ -2916,7 +2918,7 @@ def test_getattr_and_dataframe_groupby() -> None:
29162918
with pytest_warns_bounded(
29172919
FutureWarning,
29182920
r"The provided callable <built-in function (min|max)> is currently using",
2919-
lower="2.0.99",
2921+
upper="2.2.99",
29202922
):
29212923
check(assert_type(df.groupby("col1").col3.agg(min), pd.Series), pd.Series)
29222924
check(

tests/test_groupby.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def test_frame_groupby_resample() -> None:
130130
with pytest_warns_bounded(
131131
FutureWarning,
132132
r"The provided callable <function (sum|mean) .*> is currently using ",
133-
lower="2.0.99",
133+
upper="2.2.99",
134134
):
135135
check(
136136
assert_type(GB_DF.resample("ME").aggregate(np.sum), DataFrame),
@@ -193,7 +193,7 @@ def df2scalar(val: DataFrame) -> float:
193193
with pytest_warns_bounded(
194194
FutureWarning,
195195
r"The provided callable <function (sum|mean) .*> is currently using ",
196-
lower="2.0.99",
196+
upper="2.2.99",
197197
):
198198
check(GB_DF.resample("ME").aggregate(np.sum), DataFrame)
199199
check(GB_DF.resample("ME").aggregate([np.mean]), DataFrame)
@@ -344,7 +344,7 @@ def test_series_groupby_resample() -> None:
344344
with pytest_warns_bounded(
345345
FutureWarning,
346346
r"The provided callable <function (sum|mean) .*> is currently using ",
347-
lower="2.0.99",
347+
upper="2.2.99",
348348
):
349349
check(
350350
assert_type(
@@ -421,7 +421,7 @@ def s2scalar(val: Series) -> float:
421421
with pytest_warns_bounded(
422422
FutureWarning,
423423
r"The provided callable <function (sum|mean) .*> is currently using ",
424-
lower="2.0.99",
424+
upper="2.2.99",
425425
):
426426
check(GB_S.resample("ME").aggregate(np.sum), Series)
427427
check(GB_S.resample("ME").aggregate([np.mean]), DataFrame)
@@ -468,7 +468,7 @@ def test_frame_groupby_rolling() -> None:
468468
with pytest_warns_bounded(
469469
FutureWarning,
470470
r"The provided callable <function (sum|mean) .*> is currently using ",
471-
lower="2.0.99",
471+
upper="2.2.99",
472472
):
473473
check(assert_type(GB_DF.rolling(1).aggregate(np.sum), DataFrame), DataFrame)
474474
check(assert_type(GB_DF.rolling(1).agg(np.sum), DataFrame), DataFrame)
@@ -512,7 +512,7 @@ def df2scalar(val: DataFrame) -> float:
512512
with pytest_warns_bounded(
513513
FutureWarning,
514514
r"The provided callable <function (sum|mean) .*> is currently using ",
515-
lower="2.0.99",
515+
upper="2.2.99",
516516
):
517517
check(GB_DF.rolling(1).aggregate(np.sum), DataFrame)
518518
check(GB_DF.rolling(1).aggregate([np.mean]), DataFrame)
@@ -590,7 +590,7 @@ def test_series_groupby_rolling() -> None:
590590
with pytest_warns_bounded(
591591
FutureWarning,
592592
r"The provided callable <function (sum|mean) .*> is currently using ",
593-
lower="2.0.99",
593+
upper="2.2.99",
594594
):
595595
check(assert_type(GB_S.rolling(1).aggregate("sum"), Series), Series)
596596
check(assert_type(GB_S.rolling(1).aggregate(np.sum), Series), Series)
@@ -663,7 +663,7 @@ def test_frame_groupby_expanding() -> None:
663663
with pytest_warns_bounded(
664664
FutureWarning,
665665
r"The provided callable <function (sum|mean) .*> is currently using ",
666-
lower="2.0.99",
666+
upper="2.2.99",
667667
):
668668
check(assert_type(GB_DF.expanding(1).aggregate(np.sum), DataFrame), DataFrame)
669669
check(assert_type(GB_DF.expanding(1).agg(np.sum), DataFrame), DataFrame)
@@ -709,7 +709,7 @@ def df2scalar(val: DataFrame) -> float:
709709
with pytest_warns_bounded(
710710
FutureWarning,
711711
r"The provided callable <function (sum|mean) .*> is currently using ",
712-
lower="2.0.99",
712+
upper="2.2.99",
713713
):
714714
check(GB_DF.expanding(1).aggregate(np.sum), DataFrame)
715715
check(GB_DF.expanding(1).aggregate([np.mean]), DataFrame)
@@ -789,7 +789,7 @@ def test_series_groupby_expanding() -> None:
789789
with pytest_warns_bounded(
790790
FutureWarning,
791791
r"The provided callable <function (sum|mean) .*> is currently using ",
792-
lower="2.0.99",
792+
upper="2.2.99",
793793
):
794794
check(assert_type(GB_S.expanding(1).aggregate("sum"), Series), Series)
795795
check(assert_type(GB_S.expanding(1).aggregate(np.sum), Series), Series)
@@ -857,7 +857,7 @@ def test_frame_groupby_ewm() -> None:
857857
with pytest_warns_bounded(
858858
FutureWarning,
859859
r"The provided callable <function (sum|mean) .*> is currently using ",
860-
lower="2.0.99",
860+
upper="2.2.99",
861861
):
862862
check(assert_type(GB_DF.ewm(1).aggregate(np.sum), DataFrame), DataFrame)
863863
check(assert_type(GB_DF.ewm(1).agg(np.sum), DataFrame), DataFrame)
@@ -888,7 +888,7 @@ def test_frame_groupby_ewm() -> None:
888888
with pytest_warns_bounded(
889889
FutureWarning,
890890
r"The provided callable <function (sum|mean) .*> is currently using ",
891-
lower="2.0.99",
891+
upper="2.2.99",
892892
):
893893
check(GB_DF.ewm(1).aggregate(np.sum), DataFrame)
894894
check(GB_DF.ewm(1).aggregate([np.mean]), DataFrame)
@@ -961,7 +961,7 @@ def test_series_groupby_ewm() -> None:
961961
with pytest_warns_bounded(
962962
FutureWarning,
963963
r"The provided callable <function (sum|mean) .*> is currently using ",
964-
lower="2.0.99",
964+
upper="2.2.99",
965965
):
966966
check(assert_type(GB_S.ewm(1).aggregate("sum"), Series), Series)
967967
check(assert_type(GB_S.ewm(1).aggregate(np.sum), Series), Series)

tests/test_indexes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from pandas._typing import Dtype # noqa: F401
1515

1616
from tests import (
17+
PD_LTE_22,
1718
TYPE_CHECKING_INVALID_USAGE,
1819
check,
1920
pytest_warns_bounded,
@@ -866,7 +867,11 @@ def test_getitem() -> None:
866867
iri = pd.RangeIndex(0, 10)
867868
check(assert_type(iri, pd.RangeIndex), pd.RangeIndex, int)
868869
check(assert_type(iri[0], int), int)
869-
check(assert_type(iri[[0, 2, 4]], pd.Index), pd.Index, np.integer)
870+
check(
871+
assert_type(iri[[0, 2, 4]], pd.Index),
872+
pd.Index,
873+
np.integer if PD_LTE_22 else int,
874+
)
870875

871876
mi = pd.MultiIndex.from_product([["a", "b"], ["c", "d"]], names=["ab", "cd"])
872877
check(assert_type(mi, pd.MultiIndex), pd.MultiIndex)

tests/test_io.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@
4949
from typing_extensions import assert_type
5050

5151
from tests import (
52-
PD_LTE_22,
5352
TYPE_CHECKING_INVALID_USAGE,
5453
WINDOWS,
5554
check,
56-
pytest_warns_bounded,
5755
)
5856

5957
from pandas.io.api import to_pickle
@@ -428,23 +426,15 @@ def test_hdf_series():
428426

429427

430428
def test_spss():
431-
if PD_LTE_22:
432-
warning_class = FutureWarning
433-
message = "Placeholder"
434-
else:
435-
warning_class = pd.errors.ChainedAssignmentError # type: ignore[attr-defined] # pyright: ignore[reportAttributeAccessIssue]
436-
message = "A value is trying to be set on a copy of a DataFrame"
437-
438429
path = Path(CWD, "data", "labelled-num.sav")
439-
with pytest_warns_bounded(warning_class, message, "2.3.0"):
440-
check(
441-
assert_type(read_spss(path, convert_categoricals=True), DataFrame),
442-
DataFrame,
443-
)
444-
check(
445-
assert_type(read_spss(str(path), usecols=["VAR00002"]), DataFrame),
446-
DataFrame,
447-
)
430+
check(
431+
assert_type(read_spss(path, convert_categoricals=True), DataFrame),
432+
DataFrame,
433+
)
434+
check(
435+
assert_type(read_spss(str(path), usecols=["VAR00002"]), DataFrame),
436+
DataFrame,
437+
)
448438

449439

450440
def test_json():

0 commit comments

Comments
 (0)