Skip to content

Add a make-parameter-keyword-only-with-deprecation decorator. #13601

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
Mar 13, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 6, 2019

(discussed in #13128 (comment))

... and use it to make the block argument of plt.show() keyword only
(with deprecation), with the idea of making the future signature
plt.show(figures=None, *, block=True) (discussed in #13590).

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.1.0 milestone Mar 6, 2019
@QuLogic
Copy link
Member

QuLogic commented Mar 6, 2019

I'm not sure the title of this PR/commit is the same as what it's doing.

@@ -242,6 +242,12 @@ def trigger_manager_draw(manager):

@staticmethod
def show(*args, **kwargs):
if args or {*kwargs} - {"block"}:
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't that be simply

def show(*args, *, block=None, **kwargs):
    if args or kwargs:

Note also that block is not used within the method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it's legal to do show(block=...); sure, block is not used but I don't want to emit a deprecation in that case as that makes it harder to write backend-independent code (or if you really want to warn, it should be something like "the block parameter has no effect in the nbagg backend").

Copy link
Member

Choose a reason for hiding this comment

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

Not sure what official best practices are here, but I would make all show() methods identical in their API. They override _Backend.show() and should formally be substitutable. Any non-working parameters should be warned about and not be ignored or rejected with a type error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry, I missed that you proposed changing the signature. Yes, that works, pushed.

@anntzer
Copy link
Contributor Author

anntzer commented Mar 7, 2019

@QuLogic oops :)

@anntzer anntzer changed the title Add a make-parameter-positional-only-with-deprecation decorator. Add a make-parameter-keyword-only-with-deprecation decorator. Mar 7, 2019
@anntzer anntzer force-pushed the make_positional_only branch from 9c76bd5 to 8fa77db Compare March 7, 2019 00:24
... and use it to make the `block` argument of plt.show() keyword only
(with deprecation), with the idea of making the future signature
`plt.show(figures=None, *, block=True)`.
@anntzer anntzer force-pushed the make_positional_only branch from 8fa77db to 001e85f Compare March 7, 2019 01:00
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Subject to CI.

@jklymak jklymak merged commit edf1bb7 into matplotlib:master Mar 13, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Mar 13, 2019
@anntzer anntzer deleted the make_positional_only branch March 13, 2019 22:22
jklymak added a commit that referenced this pull request Mar 13, 2019
…601-on-v3.1.x

Backport PR #13601 on branch v3.1.x (Add a make-parameter-keyword-only-with-deprecation decorator.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants