Skip to content

Remove unused @public template-global registration (url_quote, get_borrow_status) (#13422) - #13427

Merged
RayBB merged 1 commit into
internetarchive:masterfrom
shariqueahmad108-ship-it:cleanup/unused-template-globals-public-13422
Aug 25, 2026
Merged

Remove unused @public template-global registration (url_quote, get_borrow_status) (#13422)#13427
RayBB merged 1 commit into
internetarchive:masterfrom
shariqueahmad108-ship-it:cleanup/unused-template-globals-public-13422

Conversation

@shariqueahmad108-ship-it

Copy link
Copy Markdown
Contributor

Part of #13422 β€” the "Remove the @public decorator only (keep the function)" section.

What

url_quote (openlibrary/plugins/upstream/utils.py) and get_borrow_status (openlibrary/plugins/upstream/borrow.py) are exposed as Templetor template globals via the infogami @public decorator, but no template uses them. This removes the @public decorator from both. The functions stay β€” only their template-global registration is dropped.

Why it's safe

  • Zero template/JS usage β€” grepped .py, .html, .js, and .md across the repo; neither name is referenced as a template global anywhere.
  • Only direct callers, unaffected by removing @public:
    • url_quote β†’ called internally in utils.py (set_share_links calls url_quote(...)), and tested via utils.url_quote(...) in openlibrary/plugins/upstream/tests/test_utils.py.
    • get_borrow_status β†’ called internally in borrow.py (ia_loan_status).
  • No orphaned import β€” both files keep other @public decorators (utils.py has 33, borrow.py has 2 more), so the public import stays used; no new lint error (the pre-existing I001 import-sort notices in these files are untouched by this change).

Verification

  • Step 1 (grep .py/.html/.js) β€” done, zero references outside the registration.
  • Steps 2–3 (docker smoke test + make test-py-uv) β€” I don't have the full Docker environment locally (the import chain needs infogami), so I couldn't run these here. Flagging for a reviewer to confirm in CI.
  • Per the issue's note: production also renders Infogami templates stored in the DB, which can't be grepped locally β€” worth watching error tracking for template-lookup errors mentioning these names after deploy.

Scoped to just this one section per the "one PR per section" guidance. (My other section β€” helpers.py __all__ β€” is #13426.)

… get_borrow_status (internetarchive#13422)

url_quote (openlibrary/plugins/upstream/utils.py) and get_borrow_status
(openlibrary/plugins/upstream/borrow.py) are registered as Templetor template
globals via the infogami @public decorator, but no template references either.
Remove the @public decorator from both, keeping the functions.

Both are used only via direct calls / module-attribute access, so de-registering
them as template globals is safe:
- url_quote: called internally in utils.py (set_share_links) and tested via
  utils.url_quote(...) in tests/test_utils.py
- get_borrow_status: called internally in borrow.py (ia_loan_status)

Verified by grepping .py/.html/.js/.md across the repo: zero template/JS
references to either name. The `public` import stays used in both files (other
@public decorators remain), so no import is orphaned.

@RayBB RayBB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good work here. Thanks!

Put it on testing and double checked it and it works.

@RayBB
RayBB merged commit d4850c6 into internetarchive:master Aug 25, 2026
5 of 7 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants