Add typed multiple column panel model - #552
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a typed MultipleColumnPanel model to represent MultipleColumnChart.panels, while preserving Datawrapper’s keyed metadata.visualize.panels API shape during serialization and supporting both legacy and API-shaped inputs for backwards compatibility.
Changes:
- Added
MultipleColumnPanelPydantic model and updatedMultipleColumnChartto use it forpanels, including keyed-dict serialization/deserialization behavior. - Extended integration tests to cover typed panels, API keyed-dict initialization, and compatibility with the wrapper’s previous keyed-dict output shape.
- Exported
MultipleColumnPanelfromdatawrapper/datawrapper.chartsand updated documentation/examples to use the typed model.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
datawrapper/charts/multiple_column.py |
Adds MultipleColumnPanel, updates panels typing, conversion, and keyed-dict serialization/deserialization. |
tests/integration/test_multiple_column_chart.py |
Adds coverage for typed panel behavior and compatibility input shapes. |
datawrapper/charts/__init__.py |
Exports MultipleColumnPanel from datawrapper.charts. |
datawrapper/__init__.py |
Exports MultipleColumnPanel from the top-level package. |
docs/user-guide/charts/multiple-column-charts.md |
Updates examples to use MultipleColumnPanel. |
docs/user-guide/api/models.rst |
Documents the new MultipleColumnPanel model in the API reference. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
Author
|
Follow-up pushed in f40238c.
Local validation run: uv sync --frozen --extra dev --extra test --extra mypy
uv run ruff check ./datawrapper ./tests
uv run ruff format --check ./datawrapper ./tests
uv run mypy ./datawrapper --ignore-missing-imports
uv run pytestResult: Ruff and mypy passed; full pytest passed with 1112 passed, 3 skipped. |
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
MultipleColumnPanelmodel forMultipleColumnChart.panels.metadata.visualize.panelsobject.MultipleColumnPanelfromdatawrapperanddatawrapper.charts, and updates docs/examples.Fixes #495.
Evidence and compatibility notes
metadata.visualize.panelsdata in the Datawrapper API keyed-dict shape.columninside each panel value; this change uses the column as the API key and serializes only panel configuration fields as the value.extra="allow"so future Datawrapper panel options can round-trip without a wrapper release.column.Validation
uv run ruff check .uv run ruff format --check datawrapper/charts/multiple_column.py datawrapper/__init__.py datawrapper/charts/__init__.py tests/integration/test_multiple_column_chart.pyuv run pytest tests/integration/test_multiple_column_chart.py -q— 27 passeduv run pytest -q— 1108 passed, 3 skippedgit diff --checkNote:
uv run ruff format --check .reports one pre-existing formatting issue intests/integration/test_scatter_chart.pyonorigin/main, so I limited the formatter check to the files changed by this PR to avoid unrelated churn.