File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -263,11 +263,36 @@ def set_option(*args) -> None:
263
263
opt .cb (key )
264
264
return
265
265
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
267
284
nargs = len (args )
268
285
if not nargs or nargs % 2 != 0 :
269
286
raise ValueError ("Must provide an even number of non-keyword arguments" )
270
287
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
271
296
for k , v in zip (args [::2 ], args [1 ::2 ]):
272
297
key = _get_single_key (k )
273
298
You can’t perform that action at this time.
0 commit comments