Skip to content

Commit e9af63a

Browse files
fix: use contextlib.suppress to satisfy Ruff SIM105
1 parent c8ace65 commit e9af63a

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

openlibrary/plugins/upstream/borrow.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Handlers for borrowing books"""
22

3+
import contextlib
34
import copy
45
import hashlib
56
import hmac
@@ -192,11 +193,9 @@ def POST(self, key): # noqa: PLR0915
192193
raise web.seeother(redirect_url)
193194

194195
if action == 'return':
195-
try:
196+
# Try to return the loan, catching PatronAccessException explicitly so we can verify if the loan is actually gone.
197+
with contextlib.suppress(lending.PatronAccessException):
196198
lending.s3_loan_api(s3_keys, ocaid=edition.ocaid, action='return_loan')
197-
except lending.PatronAccessException:
198-
# Loan may have already expired — check status before claiming success
199-
pass
200199
stats.increment('ol.loans.return')
201200
edition.update_loan_status()
202201
user.update_loan_status()

0 commit comments

Comments
 (0)