Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fcff208

Browse files
committed
Deprecate passing keys to update_keymap as single comma-separated string
... to ToolManager.update_keymap. Probably we should pick just one signature between taking all keys as a single list or as separate `*args`, but that can occur later. This allows one to correctly set a keymap to "," (a single comma). This also will help further cleanup of rc validators (by not "leaking" validate_stringlist out of rcsetup).
1 parent 28f41f9 commit fcff208

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

doc/api/api_changes_3.3/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,3 +554,8 @@ in which they are given. This only affects the interaction between the
554554
properties: the *color* property now needs to be passed first in order not to
555555
override the other properties. This is consistent with e.g. `.Artist.update`,
556556
which did not reorder the properties passed to it.
557+
558+
Passing multiple keys as a single comma-separated string to `.ToolManager.update_keymap`
559+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
560+
This is deprecated; pass keys as separate arguments or a list of strings
561+
instead.

lib/matplotlib/backend_managers.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,20 @@ def update_keymap(self, name, *keys):
194194
keys : list of str
195195
Keys to associate with the tool.
196196
"""
197-
198197
if name not in self._tools:
199198
raise KeyError('%s not in Tools' % name)
200-
201199
self._remove_keys(name)
202-
203200
for key in keys:
204-
for k in validate_stringlist(key):
201+
if isinstance(key, str) and validate_stringlist(key) != [key]:
202+
cbook.warn_deprecated(
203+
"3.3", message="Passing a list of keys as a single "
204+
"comma-separated strings is deprecated since %(since)s "
205+
"and support will be removed %(removal)s; pass keys "
206+
"separately instead.")
207+
key = validate_stringlist(key)
208+
if isinstance(key, str):
209+
key = [key]
210+
for k in key:
205211
if k in self._keys:
206212
cbook._warn_external('Key %s changed from %s to %s' %
207213
(k, self._keys[k], name))

0 commit comments

Comments
 (0)