Skip to content

Inherit the Artist.draw docstring in subclasses. #16010

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 1 commit into from
Dec 25, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Dec 23, 2019

PR Summary

Per #16004 (comment).

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Btw, is it reasonable that we have three different signatures for draw?

    def draw(self, renderer, *args, **kwargs):
    def draw(self, renderer=None, inframe=False):
    def draw(self, renderer): 

Copy link
Contributor

@dopplershift dopplershift 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 nice cleanup. I have just the one question, but won't hold up for that because this is not making anything worse.

@@ -2613,7 +2613,7 @@ def _update_title_position(self, renderer):
# Drawing
@martist.allow_rasterization
def draw(self, renderer=None, inframe=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

What about the parameters here? They're undocumented (though they were before too).

@dopplershift
Copy link
Contributor

The 3 different signatures makes my skin crawl. By virtue of Artist.draw taking *args* and **kwargs it was clearly meant for subclasses to take additional parameters. I think the ones that abandon this with draw(self, renderer) bother me the most because they're more restrictive.

Actually, technically they're all more restrictive than their base class...

@anntzer
Copy link
Contributor Author

anntzer commented Dec 24, 2019

I would rather just always make the signature draw(self, renderer) and figure out whether we can deprecate the inframe kwarg to Figure.draw (just one special case doesn't seem sufficient to make a more complex signature worth it).

@timhoffm
Copy link
Member

timhoffm commented Dec 25, 2019

At least the base class should not have any arguments except renderer. From a design perspective, it's perfectly fine for subclasses to add additional optional arguments. No need to anticipate that with *args, **kwargs. Removing this needs deprecation but is straight forward. Looking into inframe may or may not be done simultaneously.

Anyway, that should be done in a separate PR (made an issue for that: #16022).

@timhoffm timhoffm added this to the v3.3.0 milestone Dec 25, 2019
@timhoffm timhoffm merged commit 8f33959 into matplotlib:master Dec 25, 2019
@anntzer anntzer deleted the inherit-draw-doc branch December 25, 2019 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants