Add data change transforms - #554
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
DataChangeandDataChangeListmodels and wires them intoTransform.changes, including round-tripping both list-shaped and object-map API payloads. - Exports the new models from
datawrapper,datawrapper.charts, anddatawrapper.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.
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
DataChangeandDataChangeListmodels for individual value corrections stored inmetadata.data.changesfrom Datawrapper's Check & Describe step.Transform.changesand package exports, while omitting empty changes from default serialization.Verified configuration shape
metadata.data.changesas a list of objects with zero-basedrowandcolumn, replacementvalue, edittimein Unix milliseconds, and optionalprevious.metadata.data.changesas an object keyed by Datawrapper internal IDs. Those entries include the same core fields plus API-only fields such asid,ignored, and_index; some responses use an empty object{}for no corrections.Compatibility behavior
Transform()still does not emit an emptychangeskey.column-format,column-order, headers, transpose, external data, CDN, and upload-method serialization behavior is preserved.Tests
uv run ruff check ./datawrapper ./testsuv run ruff format --check ./datawrapper ./testsuv run mypy ./datawrapper --ignore-missing-importsuv run pytest(1114 passed, 3 skipped)uv build --sdist --wheelCloses #498.