Skip to content

fix: report missing anywidget for JupyterChart - #4089

Merged
mattijn merged 2 commits into
vega:mainfrom
dk3yyyy:fix/3801-jupyter-optional-dependency
Jul 29, 2026
Merged

fix: report missing anywidget for JupyterChart#4089
mattijn merged 2 commits into
vega:mainfrom
dk3yyyy:fix/3801-jupyter-optional-dependency

Conversation

@dk3yyyy

@dk3yyyy dk3yyyy commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add the missing enable_offline() API to the JupyterChart fallback used when anywidget is unavailable
  • detect the optional dependency with find_spec() and expose the real class during type checking
  • remove obsolete type ignores from the Jupyter renderer
  • add regression coverage for the missing-dependency behavior and restore imported module state after the test

Fixes #3801

Testing

  • uv run task test
  • uv run pytest tests/test_jupyter_chart.py -q --numprocesses=1
  • uv run pytest tests/vegalite/v6/test_renderers.py -q --numprocesses=1
  • verified a base-only installation without anywidget reports the intended ImportError for alt.JupyterChart, enable_offline(), and the jupyter renderer

@github-actions github-actions Bot added the bug label Jul 29, 2026
@mattijn

mattijn commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Thanks for this PR @dk3yyyy! Would it be possible to adapt your contribution to have the test run without a pytest.monkeypach()? I think we have a CI run that only does the base installation or at least options to have certain optional deps not included. Thanks again for this PR!

@dk3yyyy

dk3yyyy commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @mattijn! I’ve updated the test to avoid pytest.monkeypatch and module reloading. It now runs directly against alt.JupyterChart when anywidget is unavailable, using the existing Python 3.10 CI jobs where anywidget is explicitly uninstalled.

The test covers both JupyterChart.enable_offline() and construction through the public API. I also verified it locally in the equivalent no-anywidget setup: 1 passed, with the 5 tests requiring anywidget correctly skipped.

@mattijn
mattijn merged commit 4e908aa into vega:main Jul 29, 2026
14 of 36 checks passed
@mattijn

mattijn commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Thanks @dk3yyyy! CI is happy with your latest commit. Thanks!

@dk3yyyy

dk3yyyy commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge, @mattijn!

@dk3yyyy
dk3yyyy deleted the fix/3801-jupyter-optional-dependency branch July 30, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

type object 'JupyterChart' has no attribute 'enable_offline'

2 participants