44
55import inspect
66
7+ from pandas .errors import Pandas4Warning
78from pandas .util ._decorators import deprecate_nonkeyword_arguments
89
910import 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)
1518def 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
4346def 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
4851def 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
5356def 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 )
6366def 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
7780def 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
8285def 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 )
9295def 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
105108def 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
110113def 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 )
117120def 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
125128def 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
130133class 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
141142def 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" )
0 commit comments