Skip to content

Add data change transforms - #554

Merged
palewire merged 2 commits into
mainfrom
sluggo/sluggo-20260726T173944Z-77f0468c
Jul 26, 2026
Merged

Add data change transforms#554
palewire merged 2 commits into
mainfrom
sluggo/sluggo-20260726T173944Z-77f0468c

Conversation

@palewire

Copy link
Copy Markdown
Collaborator

Summary

  • Add DataChange and DataChangeList models for individual value corrections stored in metadata.data.changes from Datawrapper's Check & Describe step.
  • Wire the new public API through Transform.changes and package exports, while omitting empty changes from default serialization.
  • Document usage and add regression coverage for both documented list-shaped changes and API object-map changes.

Verified configuration shape

  • Datawrapper's developer documentation represents corrections under metadata.data.changes as a list of objects with zero-based row and column, replacement value, edit time in Unix milliseconds, and optional previous.
  • Existing repository sample API payloads also show metadata.data.changes as an object keyed by Datawrapper internal IDs. Those entries include the same core fields plus API-only fields such as id, ignored, and _index; some responses use an empty object {} for no corrections.
  • This implementation accepts both shapes and round-trips object-shaped API responses without converting them to list-shaped payloads.

Compatibility behavior

  • Existing transformations are unchanged: Transform() still does not emit an empty changes key.
  • Existing column-format, column-order, headers, transpose, external data, CDN, and upload-method serialization behavior is preserved.
  • User-authored corrections serialize as the documented list shape; API object-map responses preserve their original keys and fields.

Tests

  • uv run ruff check ./datawrapper ./tests
  • uv run ruff format --check ./datawrapper ./tests
  • uv run mypy ./datawrapper --ignore-missing-imports
  • uv run pytest (1114 passed, 3 skipped)
  • uv build --sdist --wheel

Closes #498.

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

Adds first-class support for Datawrapper “Check & Describe” value corrections stored under metadata.data.changes, exposing them through the public chart transformation API while preserving existing serialization behavior (not emitting empty changes by default).

Changes:

  • Introduces DataChange and DataChangeList models and wires them into Transform.changes, including round-tripping both list-shaped and object-map API payloads.
  • Exports the new models from datawrapper, datawrapper.charts, and datawrapper.charts.models.
  • Adds documentation plus unit-fixture regression tests for both documented (list) and observed (object-map / {}) API shapes.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
datawrapper/charts/models/transforms.py Adds DataChange / DataChangeList and integrates them into Transform.changes with shape-preserving serialization.
datawrapper/charts/models/__init__.py Re-exports DataChange and DataChangeList from the models package.
datawrapper/charts/__init__.py Surfaces DataChange and DataChangeList in the charts-level public API exports.
datawrapper/__init__.py Exposes DataChange and DataChangeList at the top-level datawrapper import.
docs/user-guide/api/models.rst Documents DataChange / DataChangeList usage and the accepted/round-tripped API shapes.
tests/unit/models/test_transform.py Adds unit coverage for serialization, optional fields, shape handling, empty {} handling, and object-map round-tripping.
tests/fixtures/metadata_data_changes.json Adds a documented-shape fixture for round-trip validation through Transform.
tests/integration/test_scatter_chart.py Minor formatting adjustment to a list comprehension in an existing integration test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@palewire
palewire merged commit 74c49ed into main Jul 26, 2026
18 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.

Add a class-based method for sending changes for values up via the transform methods

2 participants