fix(salary): print the privacy footnote only when a row rendered N/A* (#475)

format_entry appended "* N/A = Too few employees to publish (privacy)"
under every category table, including one where every row has an index,
so the output asserted a suppression that never happened - the residual
noted on #470. Set a flag in the N/A* branch and print the footnote only
when it fired; a table with a suppressed row renders exactly as before.

Two FormatEntryTests cases pin both directions; the "omitted" case fails
on master.
This commit is contained in:
Ayobami Adegoke
2026-09-16 21:06:23 +02:00
committed by GitHub
parent 968fb1bd7e
commit b91c6125ec
3 changed files with 47 additions and 1 deletions
+7 -1
View File
@@ -319,6 +319,7 @@ def format_entry(entry, metadata):
lines.append(f" {'Category':<22} {'Count':>6} {index_label:>8} {'vs Baseline':>10}")
lines.append(f" {'-'*50}")
suppressed = False # did any row render its index as N/A*?
for label, data in categories.items():
display_label = label.replace("_", " ").title()
count = data.get("count")
@@ -339,9 +340,14 @@ def format_entry(entry, metadata):
else:
index_str = "N/A*"
diff_str = ""
suppressed = True
lines.append(f" {display_label:<22} {count_str:>6} {index_str:>8} {diff_str:>10}")
lines.append(f"\n * N/A = Too few employees to publish (privacy)")
# The footnote explains the N/A* marker; printing it under a table with
# no such row asserts a privacy suppression that did not happen.
lines.append("")
if suppressed:
lines.append(" * N/A = Too few employees to publish (privacy)")
if metadata.get("baseline_description"):
lines.append(f" {metadata['baseline_description']}")
else: