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

Skip to content

Expire deprecations in widgets and keyword only arguments for Selectors #24254

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 4 commits into from
Jan 12, 2023

Conversation

oscargus
Copy link
Member

@oscargus oscargus commented Oct 22, 2022

PR Summary

Will add notes etc, but think about the keyword-only aspect of Selectors/Widgets. Also, lineprops is unused in RectangleSelector, but I guess I cannot really remove it?

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@greglucas
Copy link
Contributor

I think this is only missing a removal note?

@QuLogic
Copy link
Member

QuLogic commented Dec 15, 2022

Also, lineprops is unused in RectangleSelector, but I guess I cannot really remove it?

It's decorated with delete_parameter, so it should be removed.

@tacaswell
Copy link
Member

Agree with Elliott that we can fully remove drawtype, but the UI won't let me add the patches. Also agree with Greg that this needs a removal note.

@oscargus
Copy link
Member Author

The main thing here is the modified keyword only arguments. I wanted some feedback on that before continuing with release notes. But I take it that it makes sense, at least sort of.

Will get to the release notes then.

@oscargus oscargus force-pushed the widgetsexpiration branch 3 times, most recently from 648b4a8 to 6155b7e Compare December 15, 2022 21:12
"""

def __init__(self, ax, xy, callback=None, useblit=True):
@_api.make_keyword_only("3.7", name="useblit")
def __init__(self, ax, xy, callback, useblit=True):
Copy link
Member Author

Choose a reason for hiding this comment

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

callback cannot be None, so it doesn't make sense to have a default value (despite this going back 17 years...).

Copy link
Member

Choose a reason for hiding this comment

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

I'm inclinded that we want callback keyword-only as well.

FYI you can have keyword-only arguments without a default. This is valid:

def __init__(self, ax, xy, *, callback, useblit=True):

and would be called as

Lasso(ax, xy, callback=foo)

However, to be checked whether make_keyword_only does work correctly for such a situation.

Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit skeptical of changing callback to be keyword only. The only place we use this in a demo it is passed positionally. I am worried that we are going to get minor payoff at the cost of thrashing a bunch of user code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would not make it kwonly; it should be pretty clear in the context that that argument is a callback. The point of making e.g. useblit kwonly is that if you write Lasso(ax, xy, somefunc, True), it is really not clear what True is (useblit=True is clearer), but it is quite obvious that somefunc is a callback (especially as it'll typically have a more meaningful name, e.g. onselect; if it's a lambda defined inline (Lasso(ax, xy, lambda vertices: ...)) the situation is also clear).

def __init__(self, ax, onselect=None, useblit=True, props=None,
button=None):
@_api.make_keyword_only("3.7", name="useblit")
def __init__(self, ax, onselect, useblit=True, props=None, button=None):
Copy link
Member Author

Choose a reason for hiding this comment

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

onselect cannot be None (and isn't in any other Selector).

@oscargus oscargus added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Dec 15, 2022
@oscargus oscargus marked this pull request as ready for review December 15, 2022 21:30
"""

def __init__(self, ax, xy, callback=None, useblit=True):
@_api.make_keyword_only("3.7", name="useblit")
def __init__(self, ax, xy, callback, useblit=True):
Copy link
Member

Choose a reason for hiding this comment

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

I'm inclinded that we want callback keyword-only as well.

FYI you can have keyword-only arguments without a default. This is valid:

def __init__(self, ax, xy, *, callback, useblit=True):

and would be called as

Lasso(ax, xy, callback=foo)

However, to be checked whether make_keyword_only does work correctly for such a situation.


- The *lineprops* argument is removed, use *props* instead.
- The ``onpress`` and ``onrelease`` methods are removed. They are straight
aliases for ``press`` and ``release``.
Copy link
Member

Choose a reason for hiding this comment

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

Removal of TextBox.DIST_FROM_LEFT is missing.

Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW this is all just copied and pasted from the 3.5 release notes and deprecated replaced with removed (more or less).

But I will of course edit accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this was deprecated in bd9ee5e but we did not get a API change note with it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I update this to be deprecated in 3.7?

Copy link
Member

Choose a reason for hiding this comment

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

It has been warning, but was not documented. The conservative thing to do is put it back, document it removed in 3.7 and drop it in 3.8, but I'm inclined to be a bit YOLO here and just document that it is removed in 3.7 as this is a very niche feature...

@tacaswell
Copy link
Member

I think the outstanding tasks here are:

  • document TextBox.DIST_FROM_LEFT is removed. maybe retroactively add it to the API docs for 3.6.
  • drop the extra ()
  • rebase

@timhoffm
Copy link
Member

timhoffm commented Jan 6, 2023

Optional: #24254 (comment)

It would be nice to directly include callback while we're at making things kwonly. But if that's to complicated, we can defer that.

We do not actually use it in the code so also remove setting it.
@greglucas greglucas merged commit aa426be into matplotlib:main Jan 12, 2023
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jan 12, 2023
oscargus added a commit that referenced this pull request Jan 12, 2023
…254-on-v3.7.x

Backport PR #24254 on branch v3.7.x (Expire deprecations in widgets and keyword only arguments for Selectors)
@oscargus oscargus deleted the widgetsexpiration branch January 12, 2023 21:58
@ksunden ksunden mentioned this pull request Feb 20, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: changes Maintenance Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: widgets/UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants