Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

making onselect a keyword argument on selectors#26000

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
timhoffm merged 1 commit intomatplotlib:mainfromthiagoluisbecker:onselect_noop
Sep 20, 2024

Conversation

thiagoluisbecker
Copy link
Contributor

PR summary

closes#21929
Making onselect a keyword argument on Selectors(widgets.py) with no-op functions following the suggestion made in this issue comment:#21929 (comment).

PR checklist

@thiagoluisbeckerthiagoluisbecker marked this pull request as draftMay 29, 2023 19:38
@thiagoluisbeckerthiagoluisbecker marked this pull request as ready for reviewMay 29, 2023 23:39
@@ -3245,7 +3249,8 @@ class RectangleSelector(_SelectorWidget):
See also: :doc:`/gallery/widgets/rectangle_selector`
"""

def __init__(self, ax, onselect, *, minspanx=0, minspany=0, useblit=False,
def __init__(self, ax, *, onselect=None, minspanx=0,
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
def__init__(self,ax,*,onselect=None,minspanx=0,
def__init__(self,ax,onselect=None,*,minspanx=0,

The* makes it keyword only which would require deprecation etc. I think it make sense to provide a default value, but not require old code to passonselect with a keyword. (I guess you just forgot about this line.)

tacaswell reacted with thumbs up emoji
@oscargus
Copy link
Member

Not really sure about the mypy tests. I think you need to update thewidget.pyi-file, probably with the default values so that the signatures match.

Also, I think it would be good to add a "smoke test" for this. That is, call one of the selectors without anonselect callback. I'd create a new test that doesn't have an argument foronselect and then add a comment like:

# Smoke test for creating selector without callback

before that call.

@oscargus
Copy link
Member

Oh, and reading#21929 I am not sure that this closes the issue. It is clearly a good contribution taking care of parts of it though.

@tacaswelltacaswell added this to thev3.8.0 milestoneJun 1, 2023
tacaswell
tacaswell previously requested changesJun 1, 2023
Copy link
Member

@tacaswelltacaswell left a comment
edited
Loading

Choose a reason for hiding this comment

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

Agree with Oscar, changing to keyword only is a breaking change.

We should either go with just giving it a default value to make it optional (my preference) or actually do the derprecation (see the_api.make_keyword_only decorator that already exists in this file).

One way or the other we need a whats new and/or API change note.

Anyone can dismiss this review.

@tacaswell
Copy link
Member

Thank you for your work on this@thiagoluisbecker .

Could you also add a test of creatingSelector object without passing the onselect (to actually exercise the default path!).

@thiagoluisbecker
Copy link
ContributorAuthor

Hi! Apologies for the delay. I understand the suggestions and I will implement them. Thanks for the answers.

@timhoffm
Copy link
Member

ping@thiagoluisbecker. Are you still planning to work on this?

@thiagoluisbecker
Copy link
ContributorAuthor

Hi! No.

rcomer reacted with eyes emoji

@QuLogic
Copy link
Member

QuLogic commentedSep 20, 2024
edited
Loading

This seems straightforward, so I've rebased, fixed the comments, added a what's new note, and modified tests to drop theonselect argument everywhere it usednoop (but not where it usedMock withnoop).

Also note that there's alsoSpanSelector that has anonselect parameter, but it can't be made optional because thedirection parameter comes after it.

@QuLogicQuLogic marked this pull request as ready for reviewSeptember 20, 2024 07:01
Copy link
Member

@oscargusoscargus 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 deciding if it#21929 should be closed or not.

Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

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

This is a good step forward and does not bar later removal. In fact, it makes it slightly simpler since people can from now on leave outonselect if they don't need it, which will make their code forward-compatible with a possible future removal.

@timhoffm
Copy link
Member

Optional: We could deprecate for kw-only use for onselect and following arguments, which would make potential later removal simpler. But that can also be done in a follow-up.

@timhoffmtimhoffm merged commitfe6389f intomatplotlib:mainSep 20, 2024
41 of 44 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm approved these changes

@oscargusoscargusoscargus approved these changes

@tacaswelltacaswelltacaswell left review comments

Assignees
No one assigned
Projects
Status: Waiting for author
Milestone
v3.10.0
Development

Successfully merging this pull request may close these issues.

[MNT]: Deprecateonselect/onmove_callback of selectors
7 participants
@thiagoluisbecker@oscargus@tacaswell@timhoffm@QuLogic@ksunden@rcomer

[8]ページ先頭

©2009-2025 Movatter.jp