Closed
Description
Bug report
In
@cbook.deprecated("3.4")
class Mixin:
pass
class Base:
def __init__(self, x): self.x = x
class Mixed(Mixin, Base):
pass
Mixed(x=1)
the last line raises a rather puzzling
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
because the deprecation machinery grabs object.__init__
to install the deprecation emitter on Mixin
. (This is not a theoretical case, see e.g. #18675.)
There's a few possible solutions:
- "it's too rare, let's not bother"
- forbid deprecation of classes where
__init__
is not defined (which I think is the main failing case) - make
cbook.deprecated
actually create another class that inherits fromMixin
and has its own__init__
(which gets wrapped incbook.deprecated()
and just callssuper().__init__
), instead of monkey-patchingMixin
's original__init__
.
Matplotlib version
- Operating system: n/a
- Matplotlib version: HEAD
- Matplotlib backend (
print(matplotlib.get_backend())
): n/a - Python version: n/a
- Jupyter version (if applicable):
- Other libraries:
Metadata
Metadata
Assignees
Labels
No labels