Open manzt opened 5 months ago
Latest commit: f0e511ed6d4a0519467372ee82d365a602131bc2
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
The idea is to have anywidgets continue to subclass
anywidget.AnyWidget
in the same exact way, but cut outipywidgets.DOMWidget
from the inheritance chain (favoringtraitlets.HasTraits
instead).This PR also allows us to dogfood the
anywidget.MimeBundleDescriptor
work. One challenge with having widgets subclass fromipywidgets.DOMWidget
is that all public (low-level) methods for creating widgets end up in public APIs to end users (i.e., poor encapsulation of comms).Rather than polluting the top-level Widget with comms-related public methods, all comms usage is confined to the
_repr_mimebundle_
. This namespace is "private", and something that only anywidget authors would need to know about.Before
After
TODO:
FWIW, I think ideally widget authors would have more choice over the class for their widget (i.e.,
msgspec
,pydantic
,dataclass
), but this is definitely a step in the right direction. If anything, it allows us to nail down APIs on the mimebundle descriptor that are "essential".