Move random.randint default out of Pydantic model field #24
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-reviewing
ai-working
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
tech-debt
todo
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#24
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
`app/routers_v2/mlbplayers.py:40` — `offense_col: int = random.randint(1, 3)`. Pydantic evaluates field defaults at class definition time, not request time. Every MLB player gets the same random value. Use `Field(default_factory=lambda: random.randint(1, 3))`.
Priority: medium
Fixed in PR #38: #38
Changed
offense_col: int = random.randint(1, 3)tooffense_col: int = pydantic.Field(default_factory=lambda: random.randint(1, 3))inapp/routers_v2/mlbplayers.py. The bare default was evaluated once at class definition time — every instance shared the same value for the process lifetime. Thedefault_factoryensures a fresh random value per instantiation.