-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate BoxStyle._Base. #17737
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
Deprecate BoxStyle._Base. #17737
Conversation
|
||
def __call__(self, x0, y0, width, height, mutation_size, | ||
aspect_ratio=1.): | ||
return self(self, x0, y0, width, height, mutation_size, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this fail with the wrong error if __call__
is not overridden, since it no longer takes an aspect_ratio
argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but subclasses previously needed to override __call__
to get any meaningful behavior, no? previously not overriding it would result in a NotImplementedError from the base class, now you'd get a TypeError at argument binding time but I think that's close enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought they had to override transmute
before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I got it wrong just above. Users had to override transmute before, which means that the implementation of _Base.transmute is in facto mostly irrelevant for backcompat purposes. I guess I could even leave it as raising a NotImplementedError? (although I would change the error message, which would be confusing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but now nothing calls transmute
? So how would existing subclassers find out the deprecation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hum... I guess that in __call__
I can add a call to _deprecate_method_override(__class__.transmute, ...)
(and put back the old version of the code under the if transmute := _deprecate_method_override(...)
branch)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, if that works, sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New version in, but the whole thing's a bit tricky...
b109672
to
83f6a53
Compare
|
||
def __call__(self, x0, y0, width, height, mutation_size, | ||
aspect_ratio=1.): | ||
return self(self, x0, y0, width, height, mutation_size, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but now nothing calls transmute
? So how would existing subclassers find out the deprecation?
... by moving the mutation_aspect logic to FancyBboxPatch, so that boxstyles can be plain classes just implementing `__call__` and not inheriting from anything, which removes the need to inherit from a private base in `userdemo/custom_boxstyle01.py`. A similar approach could be implemented for FancyArrowStyle._Base and ConnectionStyle._Base.
If you revert the changes to |
oops, |
@anntzer, I was going through removing 3.4 deprecations and I wasn't entirely clear on what you had planned for the final state here. This looks like it can be removed in main now if you're interested in taking it out though. |
Done at #23237. Let's discuss it there. |
... by moving the mutation_aspect logic to FancyBboxPatch, so that
boxstyles can be plain classes just implementing
__call__
and notinheriting from anything, which removes the need to inherit from a
private base in
userdemo/custom_boxstyle01.py
.A similar approach could be implemented for FancyArrowStyle._Base and
ConnectionStyle._Base.
Closes #13199 (comment).
PR Summary
PR Checklist