Skip to content

Commit 3f3293f

Browse files
committed
Fixup
1 parent 4e46d69 commit 3f3293f

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

pandas/tests/util/test_deprecate_kwarg.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
import pandas._testing as tm
66

77

8-
@deprecate_kwarg("old", new_arg_name="new", klass=FutureWarning)
8+
@deprecate_kwarg(FutureWarning, "old", new_arg_name="new")
99
def _f1(new=False):
1010
return new
1111

1212

1313
_f2_mappings = {"yes": True, "no": False}
1414

1515

16-
@deprecate_kwarg("old", new_arg_name="new", mapping=_f2_mappings, klass=FutureWarning)
16+
@deprecate_kwarg(FutureWarning, "old", new_arg_name="new", mapping=_f2_mappings)
1717
def _f2(new=False):
1818
return new
1919

@@ -22,7 +22,7 @@ def _f3_mapping(x):
2222
return x + 1
2323

2424

25-
@deprecate_kwarg("old", new_arg_name="new", mapping=_f3_mapping, klass=FutureWarning)
25+
@deprecate_kwarg(FutureWarning, "old", new_arg_name="new", mapping=_f3_mapping)
2626
def _f3(new=0):
2727
return new
2828

@@ -65,12 +65,12 @@ def test_bad_deprecate_kwarg():
6565

6666
with pytest.raises(TypeError, match=msg):
6767

68-
@deprecate_kwarg("old", "new", 0)
68+
@deprecate_kwarg(FutureWarning, "old", "new", 0)
6969
def f4(new=None):
7070
return new
7171

7272

73-
@deprecate_kwarg("old", new_arg_name=None, klass=FutureWarning)
73+
@deprecate_kwarg(FutureWarning, "old", new_arg_name=None)
7474
def _f4(old=True, unchanged=True):
7575
return old, unchanged
7676

pandas/tests/util/test_deprecate_nonkeyword_arguments.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
import inspect
66

7+
from pandas.errors import Pandas4Warning
78
from pandas.util._decorators import deprecate_nonkeyword_arguments
89

910
import pandas._testing as tm
1011

12+
WARNING_CATEGORY = Pandas4Warning
13+
1114

1215
@deprecate_nonkeyword_arguments(
13-
version="1.1", allowed_args=["a", "b"], name="f_add_inputs", klass=FutureWarning
16+
WARNING_CATEGORY, allowed_args=["a", "b"], name="f_add_inputs"
1417
)
1518
def f(a, b=0, c=0, d=0):
1619
return a + b + c + d
@@ -41,25 +44,25 @@ def test_two_and_two_arguments():
4144

4245

4346
def test_three_arguments():
44-
with tm.assert_produces_warning(FutureWarning):
47+
with tm.assert_produces_warning(WARNING_CATEGORY):
4548
assert f(6, 3, 3) == 12
4649

4750

4851
def test_four_arguments():
49-
with tm.assert_produces_warning(FutureWarning):
52+
with tm.assert_produces_warning(WARNING_CATEGORY):
5053
assert f(1, 2, 3, 4) == 10
5154

5255

5356
def test_three_arguments_with_name_in_warning():
5457
msg = (
55-
"Starting with pandas version 1.1 all arguments of f_add_inputs "
58+
"Starting with pandas version 4.0 all arguments of f_add_inputs "
5659
"except for the arguments 'a' and 'b' will be keyword-only."
5760
)
58-
with tm.assert_produces_warning(FutureWarning, match=msg):
61+
with tm.assert_produces_warning(WARNING_CATEGORY, match=msg):
5962
assert f(6, 3, 3) == 12
6063

6164

62-
@deprecate_nonkeyword_arguments(version="1.1", klass=FutureWarning)
65+
@deprecate_nonkeyword_arguments(WARNING_CATEGORY)
6366
def g(a, b=0, c=0, d=0):
6467
with tm.assert_produces_warning(None):
6568
return a + b + c + d
@@ -75,20 +78,20 @@ def test_one_and_three_arguments_default_allowed_args():
7578

7679

7780
def test_three_arguments_default_allowed_args():
78-
with tm.assert_produces_warning(FutureWarning):
81+
with tm.assert_produces_warning(WARNING_CATEGORY):
7982
assert g(6, 3, 3) == 12
8083

8184

8285
def test_three_positional_argument_with_warning_message_analysis():
8386
msg = (
84-
"Starting with pandas version 1.1 all arguments of g "
87+
"Starting with pandas version 4.0 all arguments of g "
8588
"except for the argument 'a' will be keyword-only."
8689
)
87-
with tm.assert_produces_warning(FutureWarning, match=msg):
90+
with tm.assert_produces_warning(WARNING_CATEGORY, match=msg):
8891
assert g(6, 3, 3) == 12
8992

9093

91-
@deprecate_nonkeyword_arguments(version="1.1", klass=FutureWarning)
94+
@deprecate_nonkeyword_arguments(WARNING_CATEGORY)
9295
def h(a=0, b=0, c=0, d=0):
9396
return a + b + c + d
9497

@@ -103,17 +106,17 @@ def test_all_keyword_arguments():
103106

104107

105108
def test_one_positional_argument():
106-
with tm.assert_produces_warning(FutureWarning):
109+
with tm.assert_produces_warning(WARNING_CATEGORY):
107110
assert h(23) == 23
108111

109112

110113
def test_one_positional_argument_with_warning_message_analysis():
111-
msg = "Starting with pandas version 1.1 all arguments of h will be keyword-only."
112-
with tm.assert_produces_warning(FutureWarning, match=msg):
114+
msg = "Starting with pandas version 4.0 all arguments of h will be keyword-only."
115+
with tm.assert_produces_warning(WARNING_CATEGORY, match=msg):
113116
assert h(19) == 19
114117

115118

116-
@deprecate_nonkeyword_arguments(version="1.1", klass=UserWarning)
119+
@deprecate_nonkeyword_arguments(WARNING_CATEGORY)
117120
def i(a=0, /, b=0, *, c=0, d=0):
118121
return a + b + c + d
119122

@@ -123,14 +126,12 @@ def test_i_signature():
123126

124127

125128
def test_i_warns_klass():
126-
with tm.assert_produces_warning(UserWarning):
129+
with tm.assert_produces_warning(WARNING_CATEGORY):
127130
assert i(1, 2) == 3
128131

129132

130133
class Foo:
131-
@deprecate_nonkeyword_arguments(
132-
version=None, allowed_args=["self", "bar"], klass=FutureWarning
133-
)
134+
@deprecate_nonkeyword_arguments(WARNING_CATEGORY, allowed_args=["self", "bar"])
134135
def baz(self, bar=None, foobar=None): ...
135136

136137

@@ -140,8 +141,8 @@ def test_foo_signature():
140141

141142
def test_class():
142143
msg = (
143-
r"In a future version of pandas all arguments of Foo\.baz "
144+
r"Starting with pandas version 4.0 all arguments of Foo\.baz "
144145
r"except for the argument \'bar\' will be keyword-only"
145146
)
146-
with tm.assert_produces_warning(FutureWarning, match=msg):
147+
with tm.assert_produces_warning(WARNING_CATEGORY, match=msg):
147148
Foo().baz("qux", "quox")

pandas/tests/util/test_pandas_deprecation_warning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_function_warns_pandas_deprecation_warning():
1515
f1()
1616

1717

18-
@deprecate_kwarg("old", klass=PandasChangeWarning, new_arg_name="new")
18+
@deprecate_kwarg(PandasChangeWarning, "old", new_arg_name="new")
1919
def f2(new=0):
2020
return new
2121

0 commit comments

Comments
 (0)