@@ -25,6 +25,12 @@ def test_option_tools() -> None:
2525 check (assert_type (pd .reset_option ("display.width" ), None ), type (None ))
2626 check (assert_type (pd .set_option ("display.width" , 80 ), None ), type (None ))
2727 check (assert_type (pd .set_option ({"display.width" : 80 }), None ), type (None ))
28+ check (
29+ assert_type (
30+ pd .set_option ("display.max_columns" , 4 , "display.precision" , 1 ), None
31+ ),
32+ type (None ),
33+ )
2834 check (assert_type (pd .describe_option ("display.width" , False ), str ), str )
2935 check (assert_type (pd .describe_option ("display.width" , True ), None ), type (None ))
3036 check (assert_type (pd .options , Options ), DictWrapper )
@@ -34,6 +40,115 @@ def test_option_tools() -> None:
3440 assert pd .get_option ("display.width" ) == 120
3541
3642
43+ def test_set_option_overload () -> None :
44+ """Test the different overloads of `pd.set_option`."""
45+ # dict
46+ check (assert_type (pd .set_option ({"display.width" : 80 }), None ), type (None ))
47+ check (
48+ assert_type (pd .set_option ({"display.width" : 80 , "display.precision" : 6 }), None ),
49+ type (None ),
50+ )
51+
52+ # one pair of arguments
53+ check (assert_type (pd .set_option ("display.width" , 80 ), None ), type (None ))
54+ check (assert_type (pd .set_option ("display.precision" , 6 ), None ), type (None ))
55+ check (assert_type (pd .set_option ("display.max_rows" , 60 ), None ), type (None ))
56+ check (assert_type (pd .set_option ("display.max_rows" , None ), None ), type (None ))
57+ check (
58+ assert_type (pd .set_option ("display.expand_frame_repr" , True ), None ), type (None )
59+ )
60+
61+ # two pairs of arguments
62+ check (
63+ assert_type (pd .set_option ("display.width" , 80 , "display.precision" , 6 ), None ),
64+ type (None ),
65+ )
66+ check (
67+ assert_type (
68+ pd .set_option ("display.max_rows" , 60 , "display.max_columns" , 20 ), None
69+ ),
70+ type (None ),
71+ )
72+
73+ # three pairs of arguments
74+ check (
75+ assert_type (
76+ pd .set_option (
77+ "display.width" ,
78+ 80 ,
79+ "display.precision" ,
80+ 6 ,
81+ "display.max_rows" ,
82+ 60 ,
83+ ),
84+ None ,
85+ ),
86+ type (None ),
87+ )
88+
89+ # four pairs of arguments
90+ check (
91+ assert_type (
92+ pd .set_option (
93+ "display.width" ,
94+ 80 ,
95+ "display.precision" ,
96+ 6 ,
97+ "display.max_rows" ,
98+ 60 ,
99+ "display.max_columns" ,
100+ 20 ,
101+ ),
102+ None ,
103+ ),
104+ type (None ),
105+ )
106+
107+ # five pairs of arguments
108+ check (
109+ assert_type (
110+ pd .set_option (
111+ "display.width" ,
112+ 80 ,
113+ "display.precision" ,
114+ 6 ,
115+ "display.max_rows" ,
116+ 60 ,
117+ "display.max_columns" ,
118+ 20 ,
119+ "display.max_colwidth" ,
120+ 50 ,
121+ ),
122+ None ,
123+ ),
124+ type (None ),
125+ )
126+
127+
128+ def test_set_option_six_pairs () -> None :
129+ # GH 1680: set_option(pat0..pat5, val0..val5)
130+ check (
131+ assert_type (
132+ pd .set_option (
133+ "display.width" ,
134+ 80 ,
135+ "display.precision" ,
136+ 6 ,
137+ "display.max_rows" ,
138+ 60 ,
139+ "display.max_columns" ,
140+ 20 ,
141+ "display.max_colwidth" ,
142+ 50 ,
143+ "display.min_rows" ,
144+ 10 ,
145+ ),
146+ None ,
147+ ),
148+ type (None ),
149+ )
150+
151+
37152def test_specific_option () -> None :
38153 # GH 294
39154 check (assert_type (pd .options .plotting .backend , str ), str )
0 commit comments