Repository navigation
Ignore unknown response fields in companies, insiders, signals and webhooks - #21
Merged
Merged
Conversation
…bhooks Sixteen hand-written methods built dataclasses with Model(**data), which raises TypeError on the first field a newer API version adds. They now go through a shared _from_dict that keeps only declared fields, the pattern the transactions, search and generated models already use. Public signatures and return types are unchanged.
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.
Sixteen hand-written methods built dataclasses with
Model(**data)(Company,Insider,InsiderSignal,WebhookCreated,WebhookSubscription,WebhookEvent; sync and async). A dataclass constructor rejects unknown keyword arguments, so the first field a newer API version adds to one of these responses would raiseTypeErrorfor every caller.Fix: a small
_FromDictMixinwith a_from_dictthat keeps only declared fields, the same patternTransaction,SearchResultsand the generated models already use. Key conversion is unchanged (it happens in the client first). Public signatures and return types are unchanged. No otherModel(**data)construction remains in the package.Tests:
tests/test_unknown_fields.py, 18 tests (9 sync, 9 async) feeding each method a response with an extra field and asserting the call succeeds with known fields intact. Reverting one site makes its tests fail with the originalTypeError.pytest 82/82 (was 64);
codegen/check.pyin sync. No version bump; ships with the next release.