Repository navigation
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.
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.
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.
I thought they had to override transmute before?
There was a problem hiding this comment.
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.
OK, but now nothing calls transmute? So how would existing subclassers find out the deprecation?
There was a problem hiding this comment.
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.
Yea, if that works, sounds good.
There was a problem hiding this comment.
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.
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