Skip to content

Conversation

R3myG
Copy link
Contributor

@R3myG R3myG commented Sep 1, 2025

Description

This PR fixes the deprecation warning when using Dash with Jupyter notebooks by migrating from the deprecated ipykernel.comm.Comm class to the new comm module API. The fix addresses issue #3416 where Python 3.12+ shows deprecation warnings.

Root Cause: The ipykernel.comm.Comm class has been deprecated in favor of the comm module. However, the new comm.create_comm() returns a DummyComm object that doesn't have the .kernel attribute that the original code relied on.

Solution:

  • Replace ipykernel.comm.Comm with comm.create_comm
  • Refactor kernel access to use get_ipython().kernel directly instead of comm.kernel
  • This approach is more robust and follows the intended usage pattern

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Replace deprecated ipykernel.comm.Comm import with comm.create_comm
    • Refactor _send_jupyter_config_comm_request() to use IPython kernel directly
    • Refactor _request_jupyter_config() to use IPython kernel directly
    • Refactor _receive_message() callback to use IPython kernel directly
    • Ensure all linting checks pass (black, flake8, pylint)
    • Verify deprecation warning is eliminated
    • Test that Jupyter functionality remains intact
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md
  • If this PR needs a follow-up in dash docs, community thread, I have mentioned the relevant URLS as follows
    • this GitHub #PR number updates the dash docs
    • here is the show and tell thread in Plotly Dash community

Testing

No deprecation warnings - Verified with Python 3.12+ that the ipykernel.comm deprecation warning is eliminated
Pylint score: 10/10 - All static analysis checks pass
Flake8 clean - No style violations
Black formatted - Code follows project formatting standards
Functional testing - JupyterDash instantiation and core functions work correctly
Import testing - Module imports successfully without errors

Backward Compatibility

This fix maintains full backward compatibility:

  • All public APIs remain unchanged
  • Jupyter notebook functionality preserved
  • Same interface and behavior for end users
  • Only internal implementation details changed

Fixes #3416

…mm module

- Replace ipykernel.comm.Comm with comm.create_comm
- Refactor kernel access to use get_ipython().kernel directly instead of comm.kernel
- Resolves DeprecationWarning in Python 3.12+
- Maintains full backward compatibility and functionality
- Passes all linting checks (pylint 10/10, flake8 clean, black formatted)

The new comm module's DummyComm doesn't provide kernel access like the old
ipykernel.comm.Comm. This fix properly migrates to get kernel from IPython
directly, which is more robust and follows the intended usage pattern.

Fixes plotly#3416
Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃 Looks good, thank you.

@T4rk1n T4rk1n merged commit 562a574 into plotly:dev Sep 3, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] DeprecationWarning: Update dash/_jupyter.py to use comm module instead of deprecated ipykernel.comm.Comm
2 participants