Address rules: the print order, render() and expects() are used by nothing, though the changelog announces them #643

Closed
opened 2026-10-01 10:48:36 +00:00 by tiagoagueda · 1 comment
Owner

Found on 2026-09-29 in a read-only review of postulo at 95348908d, searching src, the templates, assets, the tests, the wiki and the sibling repositories for every caller of the address-rules functions.

Related to #147.

The address-rules plugin says it knows "what order it prints" and keeps an order for each of its 37 countries, but no page, document or export prints an address through it. Two functions, a wrapper and a table column are kept and tested for a feature that does not exist yet, and the changelog announces it. The code would also misprint the first time something used it.

Checked again on 2026-10-01 against main at 0a5cad587: still present; plugins/postal_rules/ is unchanged and core/postal.py:132-138 still has no caller.

  • Where:
    • plugins/postal_rules/__init__.py:151-170 (render): called only by core/postal.py:132-138 and by four tests, tests/test_postal_rules.py:166-211.
    • core/postal.py:132-138 (render, the wrapper that honours the off switch): no caller anywhere, tests included.
    • plugins/postal_rules/__init__.py:107-113 (expects, "Read by the form to mark a field"): no caller anywhere, tests included. The form marks nothing.
    • plugins/postal_rules/rules.py:59-60 (Rule.order) and the order= of every row: read only by render and by the table's self-check at tests/test_postal_rules.py:251.
    • core/postal.py:80-95 (location_line): called only by tests/test_postal_addresses.py:117.
    • What says the feature exists: the first line of plugins/postal_rules/__init__.py and of rules.py ("what order it prints"), and CHANGELOG.md:942-944 ("what order the whole thing prints in"). Where an address is shown today (core/models.py:600-615, one_line) it is in the order it was entered.
  • What render would do if it were called:
    • " ".join(joined.split()) at :167 collapses every run of white space, so a street typed on two lines (the form gives the street two rows on purpose, core/postal.py:184-190) prints as one: "1 High Street" and "Flat 2" came back as '1 High Street Flat 2'.
    • 26 of the 37 orders name no region, so a region the person typed is left out. For five of those (AT, CH, DE, GB, PT) the same row gives the region a name in calls, so the form asks for a County or a Distrito that the print-out then drops. The notes on AT and DE say this is how post is addressed there; for a value somebody typed, that is a decision to take, not to inherit.
  • Smaller leftovers in the same files:
    • plugins/postal_rules/__init__.py:127-128: if rule is None: return [] cannot be true, because rule_for always returns a Rule (rules.py:330-332).
    • plugins/postal_rules/rules.py:56-58: the comment on Rule.calls names a labels.py that does not exist; the words are in LABELS in __init__.py.
  • Why it matters: the maintainer keeps code, a 37-row column and tests that guard nothing a person can reach, and the documentation promises a behaviour Postulo does not have. When a letter or an export starts printing an address, the obvious function to call is this one, with the two defects above.
  • Fix: decide whether Postulo prints addresses in country order.
    • If it does: call postal.render(address, person=…) where an address is shown as lines, keep the street's own lines, and settle what happens to a typed region the country's order does not list (append it after the town, or say on the form that it is not printed).
    • If it does not, or not yet: remove render (both), expects, location_line, the order column and their tests, and correct the two docstrings and the changelog entry.
    • Either way, remove the dead rule is None branch and correct the labels.py comment.

Related to #308, under which a CV prints a town and a country and never the street, so a CV is not the caller this code is waiting for.

Done when

  • Either a page or document renders an address through postal.render, with a test in tests/test_postal_rules.py that a two-line street stays two lines and a typed region is not lost without the form saying so;
  • or a test in tests/test_postal_rules.py asserts that postal_rules exports no render and no expects, and the docstrings and CHANGELOG.md no longer mention a print order.
Found on 2026-09-29 in a read-only review of postulo at 95348908d, searching `src`, the templates, `assets`, the tests, the wiki and the sibling repositories for every caller of the address-rules functions. Related to #147. The address-rules plugin says it knows "what order it prints" and keeps an `order` for each of its 37 countries, but no page, document or export prints an address through it. Two functions, a wrapper and a table column are kept and tested for a feature that does not exist yet, and the changelog announces it. The code would also misprint the first time something used it. Checked again on 2026-10-01 against `main` at `0a5cad587`: still present; `plugins/postal_rules/` is unchanged and `core/postal.py:132-138` still has no caller. - **Where:** - `plugins/postal_rules/__init__.py:151-170` (`render`): called only by `core/postal.py:132-138` and by four tests, `tests/test_postal_rules.py:166-211`. - `core/postal.py:132-138` (`render`, the wrapper that honours the off switch): no caller anywhere, tests included. - `plugins/postal_rules/__init__.py:107-113` (`expects`, "Read by the form to mark a field"): no caller anywhere, tests included. The form marks nothing. - `plugins/postal_rules/rules.py:59-60` (`Rule.order`) and the `order=` of every row: read only by `render` and by the table's self-check at `tests/test_postal_rules.py:251`. - `core/postal.py:80-95` (`location_line`): called only by `tests/test_postal_addresses.py:117`. - What says the feature exists: the first line of `plugins/postal_rules/__init__.py` and of `rules.py` ("what order it prints"), and `CHANGELOG.md:942-944` ("what order the whole thing prints in"). Where an address is shown today (`core/models.py:600-615`, `one_line`) it is in the order it was entered. - **What `render` would do if it were called:** - `" ".join(joined.split())` at `:167` collapses every run of white space, so a street typed on two lines (the form gives the street two rows on purpose, `core/postal.py:184-190`) prints as one: "1 High Street" and "Flat 2" came back as `'1 High Street Flat 2'`. - 26 of the 37 orders name no `region`, so a region the person typed is left out. For five of those (AT, CH, DE, GB, PT) the same row gives the region a name in `calls`, so the form asks for a *County* or a *Distrito* that the print-out then drops. The notes on AT and DE say this is how post is addressed there; for a value somebody typed, that is a decision to take, not to inherit. - **Smaller leftovers in the same files:** - `plugins/postal_rules/__init__.py:127-128`: `if rule is None: return []` cannot be true, because `rule_for` always returns a `Rule` (`rules.py:330-332`). - `plugins/postal_rules/rules.py:56-58`: the comment on `Rule.calls` names a `labels.py` that does not exist; the words are in `LABELS` in `__init__.py`. - **Why it matters:** the maintainer keeps code, a 37-row column and tests that guard nothing a person can reach, and the documentation promises a behaviour Postulo does not have. When a letter or an export starts printing an address, the obvious function to call is this one, with the two defects above. - **Fix:** decide whether Postulo prints addresses in country order. - If it does: call `postal.render(address, person=…)` where an address is shown as lines, keep the street's own lines, and settle what happens to a typed region the country's order does not list (append it after the town, or say on the form that it is not printed). - If it does not, or not yet: remove `render` (both), `expects`, `location_line`, the `order` column and their tests, and correct the two docstrings and the changelog entry. - Either way, remove the dead `rule is None` branch and correct the `labels.py` comment. Related to #308, under which a CV prints a town and a country and never the street, so a CV is not the caller this code is waiting for. ## Done when - Either a page or document renders an address through `postal.render`, with a test in `tests/test_postal_rules.py` that a two-line street stays two lines and a typed region is not lost without the form saying so; - or a test in `tests/test_postal_rules.py` asserts that `postal_rules` exports no `render` and no `expects`, and the docstrings and `CHANGELOG.md` no longer mention a print order.
tiagoagueda added this to the 0.6.0 milestone 2026-10-01 10:48:36 +00:00
Author
Owner

Landed on main with a green Forgejo CI run. Its entry in the CHANGELOG's Unreleased section ends in (#643).

Landed on main with a green Forgejo CI run. Its entry in the CHANGELOG's Unreleased section ends in (#643).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Postulo/postulo#643
No description provided.