From b0a8d87d4f7672da853c854eda867f829def69fb Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 25 Feb 2026 08:54:58 -0600 Subject: [PATCH 1/2] fix: diff should use "intersection" of fields by default if either "old" or "new" data has more fields than the other set, only the fields they have in common should be used unless caller overrides --- src/wuttjamaican/diffs.py | 6 +++++- tests/test_diffs.py | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/wuttjamaican/diffs.py b/src/wuttjamaican/diffs.py index 38e4214..47db028 100644 --- a/src/wuttjamaican/diffs.py +++ b/src/wuttjamaican/diffs.py @@ -83,7 +83,11 @@ class Diff: # pylint: disable=too-many-instance-attributes self.cell_padding = cell_padding def make_fields(self): # pylint: disable=missing-function-docstring - return sorted(set(self.old_data) | set(self.new_data), key=lambda x: x.lower()) + if self.old_data and self.new_data: + fields = set(self.old_data) & set(self.new_data) + else: + fields = set(self.old_data or self.new_data) + return sorted(fields, key=lambda f: f.lower()) def render_html(self, template=None, **kwargs): """ diff --git a/tests/test_diffs.py b/tests/test_diffs.py index 32dedeb..dfb4452 100644 --- a/tests/test_diffs.py +++ b/tests/test_diffs.py @@ -19,13 +19,20 @@ class TestDiff(ConfigTestCase): self.assertEqual(diff.cell_padding, "0.5rem") def test_make_fields(self): - old_data = {"foo": "bar"} - new_data = {"foo": "bar", "baz": "zer"} + + # should return "sorted intersection" of fields + old_data = {"foo": "bar", "baz": "abc"} + new_data = {"foo": "bar", "baz": "xyz", "flurg": "foo"} # nb. this calls make_fields() diff = self.make_diff(old_data, new_data) - # TODO: should the fields be cumulative? or just use new_data? self.assertEqual(diff.fields, ["baz", "foo"]) + # all fields are used if only one data set + diff = self.make_diff(old_data, {}) + self.assertEqual(diff.fields, ["baz", "foo"]) + diff = self.make_diff({}, new_data) + self.assertEqual(diff.fields, ["baz", "flurg", "foo"]) + def test_values(self): old_data = {"foo": "bar"} new_data = {"foo": "baz"} From 55102f7b4390414862ac296a49191ced5bbd18ee Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 25 Feb 2026 08:59:16 -0600 Subject: [PATCH 2/2] =?UTF-8?q?bump:=20version=200.28.7=20=E2=86=92=200.28?= =?UTF-8?q?.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1897120..20ff297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to WuttJamaican will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## v0.28.8 (2026-02-25) + +### Fix + +- diff should use "intersection" of fields by default + ## v0.28.7 (2026-02-17) ### Fix diff --git a/pyproject.toml b/pyproject.toml index 1cd82a5..08ea1d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "WuttJamaican" -version = "0.28.7" +version = "0.28.8" description = "Base package for Wutta Framework" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@wuttaproject.org"}]