store: PR review: paper-dynasty-database#50 — None guard in pitcher sorting (APPROVED)
This commit is contained in:
parent
095fec5b76
commit
ef519b2ebf
@ -0,0 +1,29 @@
|
||||
---
|
||||
id: 38e7784c-1250-4123-9a20-1a75ad1e37d8
|
||||
type: workflow
|
||||
title: "PR review: paper-dynasty-database#50 — None guard in pitcher sorting (APPROVED)"
|
||||
tags: [pr-reviewer, paper-dynasty-database, python, peewee, fastapi, fix, none-guard]
|
||||
importance: 0.4
|
||||
confidence: 0.8
|
||||
created: "2026-03-04T02:18:09.362984+00:00"
|
||||
updated: "2026-03-04T02:18:09.362984+00:00"
|
||||
---
|
||||
|
||||
## PR #50: fix: guard against None rating objects in pitcher sorting functions
|
||||
|
||||
**Verdict:** APPROVED (posted as COMMENT — Gitea prevents self-approval)
|
||||
|
||||
### Files Reviewed
|
||||
- `app/routers_v2/teams.py`
|
||||
|
||||
### Summary
|
||||
Fixed `AttributeError` crash in two `get_total_ops` inner functions when `PitchingCardRatings.get_or_none()` returns `None` for vs-L or vs-R ratings. Both locations patched: `sort_pitchers()` (~line 593) and `sort_starters()` closure inside `get_team_sp()` (~line 670).
|
||||
|
||||
### Key Points
|
||||
- `float("inf")` used as sentinel — correct since sort is ascending (lower OPS = better pitcher), so missing-ratings pitchers sort to end
|
||||
- Explicit None check is cleaner than try/except for get_or_none() contract
|
||||
- Slight inconsistency with DH path (uses try/except AttributeError) but acceptable
|
||||
- The two `get_total_ops` implementations are nearly identical — potential consolidation opportunity noted as suggestion
|
||||
|
||||
### Pattern
|
||||
paper-dynasty-database uses `get_or_none()` throughout for safe DB lookups; callers must always guard the return value before attribute access.
|
||||
Loading…
Reference in New Issue
Block a user