Skip to content

Make function signatures more explicit #10830

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
Mar 18, 2018

Conversation

timhoffm
Copy link
Member

PR Summary

As proposed in #9912 (comment), more explicit signatures help to understand how a function works.

This PR does only contain simple cases, in which the arguments are handed down to another function (e.g. pyplot function -> Figure method). Up to now, the outer function was often *args, **kwargs. I explicitly copy parts (or the whole) of the inner function signature to the outer function. The PR is limited to cases, that do not change possible calls (e.g. certain combination of args and kwargs).

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

LGTM pending CI

@@ -471,8 +471,8 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs):
return t

@docstring.dedent_interpd
def annotate(self, *args, **kwargs):
a = mtext.Annotation(*args, **kwargs)
def annotate(self, text, xy, **kwargs):
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 annotate can sometimes take a second xy (for the other end of the arrow)

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops. Yeah, the explicit kwargs of the inner method could be passed as positional.

@timhoffm timhoffm force-pushed the explicit-args-signature branch from 163e48f to 7433f66 Compare March 18, 2018 18:54
Copy link
Member

@efiring efiring left a comment

Choose a reason for hiding this comment

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

Good.

@efiring efiring merged commit f9f7d52 into matplotlib:master Mar 18, 2018
@tacaswell tacaswell added this to the v3.0 milestone Mar 18, 2018
@timhoffm timhoffm deleted the explicit-args-signature branch March 18, 2018 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants