Add a make-parameter-keyword-only-with-deprecation decorator.#13601
Add a make-parameter-keyword-only-with-deprecation decorator.#13601jklymak merged 1 commit intomatplotlib:masterfrom
Conversation
|
I'm not sure the title of this PR/commit is the same as what it's doing. |
|
|
||
| @staticmethod | ||
| def show(*args, **kwargs): | ||
| if args or {*kwargs} - {"block"}: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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").
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Oh sorry, I missed that you proposed changing the signature. Yes, that works, pushed.
|
@QuLogic oops :) |
9c76bd5 to
8fa77db
Compare
... 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)`.
8fa77db to
001e85f
Compare
…deprecation decorator.
…601-on-v3.1.x Backport PR #13601 on branch v3.1.x (Add a make-parameter-keyword-only-with-deprecation decorator.)
(discussed in #13128 (comment))
... and use it to make the
blockargument 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