Skip to content

Commit dda273e

Browse files
committed
Report unobservable SPSS dictionary features
1 parent 44746c6 commit dda273e

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎src/openstatspec/spss/sav.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ def _sha256(path: Path) -> str:
139139
return digest.hexdigest()
140140

141141
def _import_loss_report(meta: Any) -> tuple[dict[str, str], ...]:
142+
events = [{"code": "unobservable-source-dictionary-features", "detail": "The reader does not expose SPSS variable sets or custom file/variable attributes, so their presence cannot be established or preserved."}]
142143
if getattr(meta, "mr_sets", {}) or {}:
143-
return ({"code": "multiple-response-sets-not-exportable", "detail": "Multiple-response sets are catalogued but pyreadstat cannot write them back to SAV."},)
144-
return LossReport().events
144+
events.append({"code": "multiple-response-sets-not-exportable", "detail": "Multiple-response sets are catalogued but pyreadstat cannot write them back to SAV."})
145+
return tuple(events)
145146

146147

147148
def _export_loss_report(dataset: dict[str, Any], variables: list[dict[str, Any]]) -> tuple[dict[str, str], ...]:

‎tests/test_cli.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_cli_import_inspect_validate_and_export_emit_json(tmp_path, capsys) -> N
1818
inspected = json.loads(capsys.readouterr().out)
1919
assert inspected["source_format"] == "SAV"
2020
assert inspected["source_sha256"]
21-
assert inspected["loss_report"] == []
21+
assert inspected["loss_report"][0]["code"] == "unobservable-source-dictionary-features"
2222
assert imported["case_count"] == 1
2323

2424
assert openstatspec.cli.main(["validate", "--database-url", database, "--dataset-id", "fixture"]) == 0

0 commit comments

Comments
 (0)