Skip to content

Commit 382ed6b

Browse files
lokeshclaude
andcommitted
fix: resolve ruff PLR0912 and SIM105 lint errors
Add noqa for PLR0912 (too many branches) alongside existing PLR0915 suppression, and use contextlib.suppress for the PatronAccessException catch-and-pass pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent efe5fef commit 382ed6b

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
@@ -105,7 +106,7 @@ class borrow(delegate.page):
105106
def GET(self, key):
106107
return self.POST(key)
107108

108-
def POST(self, key): # noqa: PLR0915
109+
def POST(self, key): # noqa: PLR0912, PLR0915
109110
"""Called when the user wants to borrow the edition"""
110111

111112
i = web.input(
@@ -191,10 +192,8 @@ def POST(self, key): # noqa: PLR0915
191192
raise web.seeother(redirect_url)
192193

193194
if action == 'return':
194-
try:
195+
with contextlib.suppress(lending.PatronAccessException):
195196
lending.s3_loan_api(s3_keys, ocaid=edition.ocaid, action='return_loan')
196-
except lending.PatronAccessException:
197-
pass # 400/409 — loan may already be gone; verified below
198197

199198
edition.update_loan_status()
200199
user.update_loan_status()

0 commit comments

Comments
 (0)