Skip to content

Commit 4cd314a

Browse files
committed
added deprecation warning for multiple option-value pairs
1 parent 8a720d2 commit 4cd314a

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

pandas/_config/config.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,36 @@ def set_option(*args) -> None:
263263
opt.cb(key)
264264
return
265265

266-
# must at least 1 arg deal with constraints later
266+
# Handle single option-value pair
267+
if len(args) == 2:
268+
key = _get_single_key(args[0])
269+
v = args[1]
270+
271+
opt = _get_registered_option(key)
272+
if opt and opt.validator:
273+
opt.validator(v)
274+
275+
# walk the nested dict
276+
root, k_root = _get_root(key)
277+
root[k_root] = v
278+
279+
if opt.cb:
280+
opt.cb(key)
281+
return
282+
283+
# Deprecated (# GH 61093): multiple option-value pairs as separate arguments
267284
nargs = len(args)
268285
if not nargs or nargs % 2 != 0:
269286
raise ValueError("Must provide an even number of non-keyword arguments")
270287

288+
warnings.warn(
289+
"Setting multiple options using multiple arguments is deprecated and will be "
290+
"removed in a future version. Use a dictionary instead.",
291+
FutureWarning,
292+
stacklevel=2,
293+
)
294+
295+
# Backward compatibility
271296
for k, v in zip(args[::2], args[1::2]):
272297
key = _get_single_key(k)
273298

0 commit comments

Comments
 (0)