fix(data): make Award.team optional - #347
Open
guillaumegay13 wants to merge 1 commit into
Open
guillaumegay13 wants to merge 1 commit into
guillaumegay13 wants to merge 1 commit into
Conversation
Some award recipients come back from the API without a team. In
awards/MLBHOF/recipients, seven entries (Buck O'Neil, Bud Fowler,
Marvin Miller, Bud Selig, John Schuerholz, Pat Gillick, Martin Dihigo)
have no "team" key, so get_awards("MLBHOF") raised a pydantic
ValidationError and returned nothing. MLAGG, HUTCH, MLBBSMP, MLBBCF and
MLBEXEC fail the same way. Default team to None instead.
Member
|
Thanks @gitknr I'll merge this and tag a new release. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
mlb.get_awards("MLBHOF")raises instead of returning the Hall of Fame recipients. Seven of the 354 entries the API sends forawards/MLBHOF/recipientshave noteamkey: Buck O'Neil, Bud Fowler, Marvin Miller, Bud Selig, John Schuerholz, Pat Gillick and Martin Dihigo, the executives and pioneers.Award.teamis required, so pydantic rejects the whole response:The same happens for MLAGG, HUTCH, MLBBSMP, MLBBCF and MLBEXEC.
What
Award.teambecomesOptional[Team] = None, with the docstring saying when it's missing.I left the other
Awardfields required. Every entry in these responses carries them.Tests
tests/parsers/test_awards_parser.pyfails onmainand passes here.pytest tests/ --ignore=tests/external_tests): 799 passed, 54 skipped.mlb.get_awards("MLBHOF")returns all 354 awards, 7 of them withteam=None.I didn't run the external smoke tests or the other award IDs live one by one. The five besides MLBHOF are listed from the API responses, not from calls through the client.
Risk and impact
The model now accepts a response it used to reject. Code that reads
award.teamcould now seeNone, but for these awards it used to get an exception instead.Found while testing API Bot, which we're building at Manifest: think Dependabot, but for the APIs a project calls, flagging failures and breaking changes. It's free for early adopters, happy to chat if it's useful.