Skip to content

Values Return From Set Methods #7147

Closed as not planned
Closed as not planned

Description

@rmorshea

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

Activity

  1. added this to the milestone on Sep 20, 2016
  2. tacaswell commented on Sep 20, 2016

    @tacaswell
    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.

  3. rmorshea commented on Sep 20, 2016

    @rmorshea
    ContributorAuthor

    @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
  4. tacaswell commented on Sep 21, 2016

    @tacaswell
    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.

  5. modified the milestones: , on Oct 3, 2017
  6. github-actions commented on Mar 29, 2023

    @github-actions

    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!

  7. removed this from the future releases milestone on May 2, 2023
  8. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions