Skip to content

Values Return From Set Methods #7147

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

Closed
rmorshea opened this issue Sep 20, 2016 · 4 comments
Closed

Values Return From Set Methods #7147

rmorshea opened this issue Sep 20, 2016 · 4 comments
Labels
status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. status: inactive Marked by the “Stale” Github Action

Comments

@rmorshea
Copy link
Contributor

rmorshea commented Sep 20, 2016

I've decided to review my work merging traitlets into matplotlib #4762, and during my rebase I came across this change to Artist.update...

https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/artist.py#L880

where update now handles values returned by setters.

I'm wondering what the motivation is behind these setters with return values, because they are incompatible with traitlets. If traitlets integration is to continue, these returning setters will need to be deprecated.

cc: @tacaswell, @jenshnielsen, @efiring

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Sep 20, 2016
@tacaswell
Copy link
Member

Awesome you have come back to this! This went in as part of https://github.com/matplotlib/matplotlib/pull/5599/files

I did that out of an abundance of caution to not change a different API. It looks like there are a handful of setters that do in fact return something.

I do not see why they are incompatible:

def set_foo(self, value):
    self.foo = value
    return self.foo

but agree they should go long term.

@rmorshea
Copy link
Contributor Author

rmorshea commented Sep 20, 2016

@tacaswell by "incompatible" I mean that if returning setters where an actual feature supported by matplotlib, there are certain setters that could not be replicated using traitlets.

This kind of setter could be replicated with traitlets:

def set_foo(self, value):
    new_value = change_it(value)
    self.foo = new_value
    return new_value

However something like this could not:

def set_foo(self, value):
    new_value, byproduct = change_it(value)
    self.foo = new_value
    return byproduct

@tacaswell
Copy link
Member

From a quick skim it looks like all of the returning setters return the same thing as their paired getter (ex set_title returns the Text object that is the title).

If there are any in the second class I am nominally 👍 on deprecating / addressing on a case-by-case basis.

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Oct 3, 2017
@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Mar 29, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2023
@QuLogic QuLogic removed this from the future releases milestone May 2, 2023
@rcomer rcomer added the status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. label May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. status: inactive Marked by the “Stale” Github Action
Projects
None yet
Development

No branches or pull requests

4 participants