Skip to content

Test parameter description punctuation, fix 178 violations (#340)#1664

Merged
MaxGhenis merged 1 commit into
mainfrom
vahid-ahmadi/issue-340-description-punctuation
May 23, 2026
Merged

Test parameter description punctuation, fix 178 violations (#340)#1664
MaxGhenis merged 1 commit into
mainfrom
vahid-ahmadi/issue-340-description-punctuation

Conversation

@vahid-ahmadi
Copy link
Copy Markdown
Collaborator

Summary

Closes #340 (and substantially addresses #339).

  • New structural test policyengine_uk/tests/test_parameter_descriptions.py asserts every parameter `description` field ends with a period.
  • Brings the existing 178 violating files into compliance with a one-shot mechanical edit (no semantic change).

Implementation notes

  • Multi-line descriptions are handled correctly. YAML folded scalars like

    ```yaml
    description: Percentage of the Married Couple's Allowance which is deductible from
    Income Tax Liability
    ```

    parse to a single string. The fixer locates the last continuation line and appends `.` there, so the sentence ends correctly (`...Income Tax Liability.`) — not mid-clause.

  • A handful of parameter files contain date-like keys that pyyaml's generic loader rejects with `year 0 is out of range`. The test catches `Exception` so pre-existing parse quirks don't block the assertion; PolicyEngine-core uses its own loader to read these at runtime.

Test plan

  • `pytest policyengine_uk/tests/test_parameter_descriptions.py -v` — passes.
  • `policyengine-core test policyengine_uk/tests/policy -c policyengine_uk` — 1000 passed (no regressions).
  • Manual smoke: `CountryTaxBenefitSystem` builds, sample parameter descriptions render with trailing period (e.g. `Bank of England base rate.`, `Maximum weekly Industrial Injuries Disablement Benefit; amount varies in 10% increments.`).

🤖 Generated with Claude Code

Adds `policyengine_uk/tests/test_parameter_descriptions.py` which asserts
every parameter `description` ends with a period — and brings the existing
178 parameter files into compliance. Multi-line descriptions are handled
by appending the period to the last continuation line so the sentence ends
correctly when YAML joins them.

Per #339, these descriptions surface in the UI and were inconsistent;
locking the convention in CI prevents drift going forward.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vahid-ahmadi vahid-ahmadi requested a review from MaxGhenis May 6, 2026 11:30
@vahid-ahmadi vahid-ahmadi self-assigned this May 6, 2026
Copy link
Copy Markdown
Collaborator

@MaxGhenis MaxGhenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking findings. I checked the diff against current main and the PR merges cleanly with git merge-tree; the targeted structural test passed locally in a detached worktree:

uv run pytest policyengine_uk/tests/test_parameter_descriptions.py -q

Result: 1 passed, 1 warning.

Non-blocking note: the broad PyYAML exception path currently skips 12 known files with year-0/date parsing issues. If this test gets revisited later, making that skip list explicit would avoid silently excluding future parse failures from the punctuation assertion.

@MaxGhenis MaxGhenis merged commit 28c3f6c into main May 23, 2026
9 checks passed
@MaxGhenis MaxGhenis deleted the vahid-ahmadi/issue-340-description-punctuation branch May 23, 2026 14:13
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.

Test for consistent period-ending of PolicyEngine descriptions

2 participants