Skip to content

Remove unused template globals from helpers.py __all__ (#13422) - #13426

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

Remove unused template globals from helpers.py __all__ (#13422)#13426
RayBB merged 1 commit into
internetarchive:masterfrom
shariqueahmad108-ship-it:cleanup/unused-template-globals-helpers-13422

Conversation

@shariqueahmad108-ship-it

@shariqueahmad108-ship-it shariqueahmad108-ship-it commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Part of #13422 — the openlibrary/core/helpers.py __all__ section.

What

helpers.py exposes helpers as Templetor template globals via its __all__ list (consumed at openlibrary/core/helpers.py:367, return web.storage((k, _globals[k]) for k in __all__)). Three of those are never used by any template:

  • safesort
  • private_collection_in
  • private_collections

This removes those three entries from __all__. The function definitions stay in helpers.py, and only their template-global registration is dropped.

Why it's safe

  • Zero template/JS usage — grepped .py, .html, .js, and .md across the repo; none of the three is referenced as a template global anywhere.
  • Internal callers are unaffected — they use direct imports / module-attribute access, not the template-global path:
    • safesortopenlibrary/core/models.py (from openlibrary.core.helpers import safesort), openlibrary/core/lists/model.py (h.safesort), openlibrary/tests/core/test_helpers.py (h.safesort)
    • private_collection_inopenlibrary/core/models.py (direct import)
    • private_collections → called only within helpers.py by private_collection_in()
  • No import * — there is no from openlibrary.core.helpers import * in the codebase, so __all__ feeds only the template-global builder; removing entries can't break a star-import.

Verification

  • Step 1 (grep .py/.html/.js) — done, zero references outside the registration (see above).
  • Steps 2–3 (docker smoke test + make test-py-uv) — I don't have the full Docker environment locally (the import chain requires 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.

…ve#13422)

safesort, private_collection_in, and private_collections are registered as
Templetor template globals via openlibrary/core/helpers.py __all__ (consumed at
helpers.py:367), but no template references them. Remove the three entries from
__all__ to de-register them as template globals.

The function definitions stay in helpers.py and every Python caller uses a
direct import or module-attribute access (core/models.py, core/lists/model.py,
tests/core/test_helpers.py), so they are unaffected. There is no
`from openlibrary.core.helpers import *` in the codebase, so __all__ feeds only
the template-global builder.

Verified by grepping .py/.html/.js/.md across the repo (zero template/JS
references to any of the three).

@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.

Working well and I double checked these are definitely not used on any other pages.

Thanks!

@RayBB
RayBB merged commit bc1070b 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