Skip to content

Replace deprecated web strip helpers#12507

Merged
RayBB merged 2 commits into
internetarchive:masterfrom
Abhishek764:codex/replace-web-strip-helpers
Apr 30, 2026
Merged

Replace deprecated web strip helpers#12507
RayBB merged 2 commits into
internetarchive:masterfrom
Abhishek764:codex/replace-web-strip-helpers

Conversation

@Abhishek764

Copy link
Copy Markdown
Contributor

Closes #12503

Summary

  • Replace non-vendored web.lstrips(...) calls with str.removeprefix(...).
  • Replace non-vendored web.rstrips(...) calls with str.removesuffix(...).
  • Covers the affected openlibrary/ and scripts/ files listed in the issue while preserving behavior.

Testing

  • git grep -n web\\.lstrips\\|web\\.rstrips -- . :(exclude)vendor returned no matches.
  • python -m compileall -q openlibrary/core/lists/model.py openlibrary/core/processors/readableurls.py openlibrary/coverstore/utils.py openlibrary/mocks/mock_infobase.py openlibrary/plugins/admin/code.py openlibrary/plugins/openlibrary/code.py openlibrary/plugins/openlibrary/lists.py openlibrary/plugins/upstream/code.py openlibrary/plugins/worksearch/subjects.py openlibrary/solr/update.py scripts/copydocs.py scripts/generate-api-docs.py scripts/pull-templates.py scripts/solr_updater/solr_updater.py

Note: I did not run the full test suite locally because the local environment does not have the repo test dependencies installed and this checkout expects Python >=3.12.2,<3.12.3.

@github-project-automation github-project-automation Bot moved this to Waiting Review/Merge from Staff in Ray's Project Apr 30, 2026
@mekarpeles mekarpeles requested a review from Copilot April 30, 2026 21:32
@mekarpeles

Copy link
Copy Markdown
Member

Thank you for your first pull request to Open Library, @Abhishek764! Welcome to the community.

🤖 Copilot has been assigned for an initial review.

@RayBB is assigned to this PR and currently has:

  • 4 open PR(s) of equal or higher priority to review first

Note: The linked issue (#12503) hasn't been triaged yet — triage happens on Mondays and Fridays. This doesn't block your PR from being reviewed, but priority labeling on the issue may affect queue ordering.

PR triage checklist (maintainers / Pam)
  • PR description — not empty; explains what the change does and how to verify it
  • References an issue — PR body contains a #NNN reference
    • Linked issue is triaged — has a Priority: * label (not just Needs: Triage)
    • Linked issue is assigned — has at least one assignee
  • Commit history clean — no WIP/fixup/conflict noise; commit messages are meaningful
  • CI passing — no failing check-runs
  • Test cases present — if the change touches substantive logic, test coverage exists or is explained
  • Proof of testing — PR body includes a description of what was tested, a screenshot, or a video

Note

This comment was automatically generated by Pam, Open Library's Project AI Manager, on behalf of @mekarpeles. Pam is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors the Open Library Python codebase to remove usage of deprecated web.lstrips(...) / web.rstrips(...) helpers in favor of standard-library str.removeprefix(...) / str.removesuffix(...), aligning with modern Python and reducing reliance on legacy web.py string utilities.

Changes:

  • Replaced web.lstrips(...) with str.removeprefix(...) across scripts and openlibrary/ modules.
  • Replaced web.rstrips(...) with str.removesuffix(...) across scripts and openlibrary/ modules.
  • Updated related imports where needed (some unused imports remain; see PR comments).

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/solr_updater/solr_updater.py Uses removeprefix when normalizing ol_url host for Solr updates.
scripts/pull-templates.py Uses removeprefix when mapping template keys to filesystem paths.
scripts/generate-api-docs.py Uses removeprefix when computing submodule doc paths.
scripts/copydocs.py Uses removeprefix when deriving .olrc section name from destination URL.
openlibrary/solr/update.py Uses removeprefix when normalizing host passed to Solr query config.
openlibrary/plugins/worksearch/subjects.py Uses removeprefix to derive subject path from a prefixed key.
openlibrary/plugins/upstream/code.py Uses removesuffix to normalize a root path used for dynamic documents.
openlibrary/plugins/openlibrary/lists.py Uses removeprefix when converting subject: keys to subject URLs.
openlibrary/plugins/openlibrary/code.py Uses removesuffix to normalize user_root for bot user key construction.
openlibrary/plugins/admin/code.py Uses removesuffix to normalize server URLs before appending /_reload.
openlibrary/mocks/mock_infobase.py Uses removesuffix when normalizing flattened index key suffixes.
openlibrary/coverstore/utils.py Uses removesuffix to normalize configured OL base URL.
openlibrary/core/processors/readableurls.py Uses removeprefix to compute URL “extra” after regex prefix match.
openlibrary/core/lists/model.py Uses removeprefix when generating subject URLs from subject: seed keys.

Comment thread scripts/pull-templates.py
Comment thread openlibrary/solr/update.py
Comment thread openlibrary/coverstore/utils.py

@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 great locally and on testing.

Thank you!

@RayBB RayBB merged commit 680fed3 into internetarchive:master Apr 30, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project Apr 30, 2026
Sadashii pushed a commit to Sadashii/openlibrary that referenced this pull request May 11, 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.

Replace web.lstrips and web.rstrips with modern Python alternatives

4 participants