Skip to content

Add typed multiple column panel model - #552

Merged
palewire merged 2 commits into
mainfrom
sluggo/sluggo-20260726T161927Z-c6500cc2
Jul 26, 2026
Merged

Add typed multiple column panel model#552
palewire merged 2 commits into
mainfrom
sluggo/sluggo-20260726T161927Z-c6500cc2

Conversation

@palewire

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a typed MultipleColumnPanel model for MultipleColumnChart.panels.
  • Preserves the column name as a Python attribute while serializing to Datawrapper's keyed metadata.visualize.panels object.
  • Accepts both the existing list-of-dicts input style and the keyed dict API shape for compatibility.
  • Exports MultipleColumnPanel from datawrapper and datawrapper.charts, and updates docs/examples.

Fixes #495.

Evidence and compatibility notes

  • Existing multiple-column fixtures already include real metadata.visualize.panels data in the Datawrapper API keyed-dict shape.
  • Before this change, deserialized panels were plain dictionaries, so users could not work with a typed panel model.
  • The previous serializer also included column inside each panel value; this change uses the column as the API key and serializes only panel configuration fields as the value.
  • Unknown panel fields are preserved with extra="allow" so future Datawrapper panel options can round-trip without a wrapper release.
  • Legacy list-of-dicts panel input remains supported, including dictionaries containing 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.py
  • uv run pytest tests/integration/test_multiple_column_chart.py -q — 27 passed
  • uv run pytest -q — 1108 passed, 3 skipped
  • git diff --check

Note: uv run ruff format --check . reports one pre-existing formatting issue in tests/integration/test_scatter_chart.py on origin/main, so I limited the formatter check to the files changed by this PR to avoid unrelated churn.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 MultipleColumnPanel Pydantic model and updated MultipleColumnChart to use it for panels, 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 MultipleColumnPanel from datawrapper/datawrapper.charts and 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.

Comment thread datawrapper/charts/multiple_column.py
@palewire

Copy link
Copy Markdown
Collaborator Author

Follow-up pushed in f40238c.

  • Addressed the convert_panels review feedback: keyed-dict keys are authoritative, including when value-level column conflicts, and unsupported panel item types now raise clear TypeErrors.
  • Added focused regression coverage for conflicting keyed/value column, keyed MultipleColumnPanel input, and invalid keyed/list panel items.
  • Repaired the failing Python lint/format check by applying Ruff formatting to tests/integration/test_scatter_chart.py, matching the GitHub Actions failure.

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 pytest

Result: Ruff and mypy passed; full pytest passed with 1112 passed, 3 skipped.

@palewire
palewire merged commit 7da904e into main Jul 26, 2026
17 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.

A Pydantic model for the Panel entries in a MultipleColumnChart

2 participants