Extract shared _resolve_player helper from jersey.py and checkout.py #262

Open
opened 2026-03-30 21:43:46 +00:00 by forgejo_admin · 0 comments
Contributor

Type

Feature

Lineage

Discovered scope from QA review of basketball-api PR #261 (2026-03-30).

Repo

forgejo_admin/basketball-api

User Story

As a developer
I want shared helper functions in one location
So that logic isn't duplicated across route modules

Context

PR #261 added _resolve_player() to both routes/jersey.py and routes/checkout.py. The function is identical in both files -- resolves a player from a parent's roster by optional player_id, defaulting to first player. QA flagged this as a DRY violation.

File Targets

Files the agent should modify:

  • src/basketball_api/routes/jersey.py -- remove _resolve_player, import from shared location
  • src/basketball_api/routes/checkout.py -- remove _resolve_player, import from shared location
  • src/basketball_api/helpers.py or src/basketball_api/utils.py -- create shared _resolve_player (follow existing patterns for shared helpers)

Files the agent should NOT touch:

  • src/basketball_api/auth.py -- auth logic is separate
  • Tests should be updated to import from new location if directly tested

Acceptance Criteria

  • _resolve_player exists in exactly one location
  • Both jersey.py and checkout.py import and use the shared version
  • All existing tests pass unchanged

Test Expectations

  • Existing tests pass with no changes
  • Run command: pytest tests/ -x -q

Constraints

  • Pure refactor -- no behavioral changes
  • Follow existing project patterns for shared utilities

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • project-westside-basketball
  • basketball-api PR #261 -- source of this nit
### Type Feature ### Lineage Discovered scope from QA review of basketball-api PR #261 (2026-03-30). ### Repo `forgejo_admin/basketball-api` ### User Story As a developer I want shared helper functions in one location So that logic isn't duplicated across route modules ### Context PR #261 added `_resolve_player()` to both `routes/jersey.py` and `routes/checkout.py`. The function is identical in both files -- resolves a player from a parent's roster by optional player_id, defaulting to first player. QA flagged this as a DRY violation. ### File Targets Files the agent should modify: - `src/basketball_api/routes/jersey.py` -- remove `_resolve_player`, import from shared location - `src/basketball_api/routes/checkout.py` -- remove `_resolve_player`, import from shared location - `src/basketball_api/helpers.py` or `src/basketball_api/utils.py` -- create shared `_resolve_player` (follow existing patterns for shared helpers) Files the agent should NOT touch: - `src/basketball_api/auth.py` -- auth logic is separate - Tests should be updated to import from new location if directly tested ### Acceptance Criteria - [ ] `_resolve_player` exists in exactly one location - [ ] Both jersey.py and checkout.py import and use the shared version - [ ] All existing tests pass unchanged ### Test Expectations - [ ] Existing tests pass with no changes - Run command: `pytest tests/ -x -q` ### Constraints - Pure refactor -- no behavioral changes - Follow existing project patterns for shared utilities ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `project-westside-basketball` - basketball-api PR #261 -- source of this nit
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
ldraney/basketball-api#262
No description provided.