Skip to content

Deprecate positional passing of most Artist constructor parameters #23177

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
Jun 16, 2022

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Jun 1, 2022

Follow up to and generalization of #23166.

This should have very little impact on the practical use, as it's anyway
error-prone to pass more than a few arguments by position. But enforcing
keyword-only makes future API changes simpler for us.

@timhoffm timhoffm force-pushed the constructors-kw-only branch from 0c6af5b to f6047ea Compare June 1, 2022 19:36
@timhoffm timhoffm marked this pull request as draft June 1, 2022 20:04
@timhoffm timhoffm force-pushed the constructors-kw-only branch from f6047ea to 1958b10 Compare June 1, 2022 21:49
@timhoffm timhoffm marked this pull request as ready for review June 2, 2022 18:49
Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Just a few comments on where to start the keyword only part, but overall I think this is nice for requiring explicit keywords to be used and should help with the API management.

@@ -498,6 +498,8 @@ class PaddedBox(OffsetBox):
The `.PaddedBox` contains a `.FancyBboxPatch` that is used to visualize
it when rendering.
"""

@_api.make_keyword_only("3.6", name="draw_frame")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to start at "pad" here? In AnchoredText/AnchoredBox you chose "pad".

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd leave this as proposed. If in doubt I try to err on the more permissive side, so that we don't overly constrain the API and force people to change still reasonable calls. For PaddedBox pad is quite canonical and I think we should still allow PaddedBox(child, 0.5). AnchoredText/AnchoredBox have other parameters before pad and pad as central a concept as it is with PaddedBox.

@@ -3916,6 +3927,7 @@ def __str__(self):
return s % (self._x, self._y, self._width, self._height)

@_docstring.dedent_interpd
@_api.make_keyword_only("3.6", name="bbox_transmuter")
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably start this at boxstyle since bbox_transmuter is deprecated (you could remove that here even?).

Copy link
Member Author

Choose a reason for hiding this comment

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

Started one later with mutation_scale. Same argument with erring on the permissive side `FancyBboxPatch((0, 0), 5, 8, "round") is still sort of reasonable.

This should have very little impact on the practical use, as it's anyway
error-prone to pass more than a few arguments by position. But enforcing
keyword-only makes future API changes simpler for us.
@timhoffm timhoffm force-pushed the constructors-kw-only branch from 1958b10 to aee51c8 Compare June 6, 2022 11:57
@tacaswell tacaswell added this to the v3.6.0 milestone Jun 16, 2022
Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

I am 40/40/20 between leaving it as-is, leaving pad positional in AnchoredText/AnchoredBox , and making it keyword only in PaddedBbox.

@tacaswell
Copy link
Member

@greglucas is OK with current state as discussed on the call.

@tacaswell tacaswell merged commit dab648a into matplotlib:main Jun 16, 2022
@timhoffm timhoffm deleted the constructors-kw-only branch June 16, 2022 21:52
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