Fix ipywidgets Output context manager not working with MetaKernel#365
Merged
blink1073 merged 2 commits intoCalysto:mainfrom Mar 13, 2026
Merged
Fix ipywidgets Output context manager not working with MetaKernel#365blink1073 merged 2 commits intoCalysto:mainfrom
blink1073 merged 2 commits intoCalysto:mainfrom
Conversation
Ensure comm objects created by MetaKernel have kernel=self set at construction time. This allows ipywidgets.Output.__enter__ to reach kernel.get_parent() via the comm.kernel fallback path and correctly set msg_id, making the `with output:` context manager route output to the widget as expected. Closes Calysto#217
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #365 +/- ##
==========================================
- Coverage 90.95% 90.92% -0.04%
==========================================
Files 51 51
Lines 2875 2886 +11
Branches 403 404 +1
==========================================
+ Hits 2615 2624 +9
- Misses 181 183 +2
Partials 79 79 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ipywidgets.Output'swith output:context manager failed to route output to the widget when used with MetaKernel becauseget_ipython()returnedNoneandcomm.kernelwasNoneat construction timecomm.create_comminMetaKernel.__init__to pre-setkernel=selfon newly created comms, enabling thecomm.kernelfallback path inOutput.__enter__to callkernel.get_parent()and setmsg_idcorrectlymsg_idis set/cleared correctly when entering/exiting the context managerCloses #217
Test plan
just testpasses (458 passed, 11 skipped)TestIpywidgetsOutputContextManager::test_output_widget_context_manager_sets_msg_idcovers the regression