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

Skip to content

Deprecate passing keys to update_keymap as single comma-separated string #17394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 13, 2020

... to ToolManager.update_keymap.

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).

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added this to the v3.3.0 milestone May 13, 2020
@timhoffm
Copy link
Member

By me, it would be fine to directly deprecate towards a single signature. And that signature would naturally be ...

... Um, I was going to say a single list, because update_keymap("zoom", "a", "b") is clearly a MATLABism. However, a single element list update_keymap("zoom", ["a"]) would be a common case and is also a bit weird.
I‘d go for

key : str or list of str

@anntzer
Copy link
Contributor Author

anntzer commented May 13, 2020

Yeah, asking people to write update_keymap("foo", ["a"]) when update_keymap("foo", "a") was likely the most common case is exactly why I didn't bother doing this. Let's stick to single arg which is str or list-of-str; that's the most numpy-like behavior.

@timhoffm
Copy link
Member

Docstring and deprecation message must be updated too.

... to ToolManager.update_keymap.

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).
@anntzer
Copy link
Contributor Author

anntzer commented May 14, 2020

done


Passing multiple keys as a single comma-separated string or multiple arguments to `.ToolManager.update_keymap`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is deprecated; pass keys as a list of strings instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is deprecated; pass keys as a list of strings instead.
This is deprecated; pass keys as a single string or a list of strings instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought "single string" was too confusing (as it used to be a single string before too... I guess it should be "single string if you're only passing a single key", but heh) and just documenting "list of strings" here was good enough (even though we support the single string option too).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, since this is just the deprecation notice and not the reference docstring, the imprecision is tolerable 😄 .

@timhoffm timhoffm merged commit 22eade6 into matplotlib:master May 14, 2020
@anntzer anntzer deleted the update_keymap branch May 14, 2020 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants