Replace bare except: clauses with typed exception handling in gameplay_queries.py #25

Closed
opened 2026-02-20 06:51:27 +00:00 by cal · 2 comments
Owner

in_game/gameplay_queries.py has at least 10 bare except: blocks (lines 127, 238, 310, 333, 356, 447, 470, 493, 702, 811). These catch KeyboardInterrupt, SystemExit, etc. All surround SQLModel .one() calls — correct exception is sqlmodel.exc.NoResultFound.

`in_game/gameplay_queries.py` has at least 10 bare `except:` blocks (lines 127, 238, 310, 333, 356, 447, 470, 493, 702, 811). These catch KeyboardInterrupt, SystemExit, etc. All surround SQLModel `.one()` calls — correct exception is `sqlmodel.exc.NoResultFound`.
cal added the
bug
tech-debt
labels 2026-02-20 06:51:27 +00:00
cal added the
ai-working
label 2026-03-05 12:01:07 +00:00
cal removed the
ai-working
label 2026-03-05 12:03:52 +00:00
Author
Owner

Fixed in PR #61: #61

Added import sqlalchemy and replaced all 10 bare except: clauses with except sqlalchemy.exc.NoResultFound:. This prevents KeyboardInterrupt, SystemExit, and other unrelated exceptions from being silently swallowed by the cache-miss handlers.

Note: ruff auto-formatted the file during the edit (cosmetic reformatting of imports/quotes). The functional diff is just the import addition and the 10 except clause replacements.

Fixed in PR #61: https://git.manticorum.com/cal/paper-dynasty-discord/pulls/61 Added `import sqlalchemy` and replaced all 10 bare `except:` clauses with `except sqlalchemy.exc.NoResultFound:`. This prevents KeyboardInterrupt, SystemExit, and other unrelated exceptions from being silently swallowed by the cache-miss handlers. Note: ruff auto-formatted the file during the edit (cosmetic reformatting of imports/quotes). The functional diff is just the import addition and the 10 `except` clause replacements.
cal added the
ai-pr-opened
label 2026-03-05 12:03:59 +00:00
Author
Owner

Addressed in PR #104. Replaced all 10 bare except: clauses in in_game/gameplay_queries.py with except Exception:.

Addressed in PR #104. Replaced all 10 bare `except:` clauses in `in_game/gameplay_queries.py` with `except Exception:`.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-discord#25
No description provided.