Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Fixes Matplotlib backend retrieval compatibility across versions 3.5–3.9 while preserving support for older and newer releases.
Changes:
- Uses
get_backend()for Matplotlib 3.5–3.9. - Uses
get_backend(auto_select=False)for Matplotlib ≥3.10. - Retains the legacy fallback for older versions.
| File | Description |
|---|---|
matplotlib_inline/backend_inline.py |
Adds version-aware backend retrieval logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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
This PR fixes #54 and the same issue I personally experienced with Matplotlib 3.6.3 and Python 3.11 by adding a compatibility branch in
_enable_matplotlib_integrationfor Matplotlib versions >= 3.5.0 and < 3.10.0, usingmatplotlib.get_backend()without arguments.Background
In Matplotlib 3.5.0, the private
_get()function was removed and replaced byget_backend()for retrieving the current backend.get_backend()accepted no arguments through Matplotlib 3.9.x.However,
_enable_matplotlib_integrationcurrently attempts to usematplotlib.rcParams._get("backend")for Matplotlib versions before 3.10.0. This causes the integration to fail with Matplotlib >= 3.5.0 < 3.10 because_get()is no longer available.Changes
This change uses:
matplotlib.get_backend(auto_select=False)for Matplotlib >= 3.10.0matplotlib.get_backend()for Matplotlib >= 3.5.0 and < 3.10.0matplotlib.rcParams._get("backend")for older Matplotlib versionsTesting
Confirmed that Matplotlib 3.5.0 and 3.6.3 do not include
_get().Tested with Matplotlib 3.6.3 and confirmed that
_enable_matplotlib_integrationsuccessfully retrieves the backend without raising anAttributeError.Included a CI test that verifies Matplotlib 3.5.0 and 3.9.9 work with the
matplotlib.rcParams.get_backend()function.Tested that the modified function works correctly with Python 3.10 and Python 3.11.