Skip to content

Ignore unknown response fields in companies, insiders, signals and webhooks - #21

Merged
theodor90 merged 1 commit into
mainfrom
fix/tolerate-new-fields
Oct 5, 2026
Merged

theodor90 merged 1 commit into
mainfrom
fix/tolerate-new-fields

Conversation

@theodor90

Copy link
Copy Markdown
Owner

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 raise TypeError for every caller.

Fix: a small _FromDictMixin with a _from_dict that keeps only declared fields, the same pattern Transaction, SearchResults and the generated models already use. Key conversion is unchanged (it happens in the client first). Public signatures and return types are unchanged. No other Model(**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 original TypeError.

pytest 82/82 (was 64); codegen/check.py in sync. No version bump; ships with the next release.

…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.
@theodor90
theodor90 merged commit e98dc56 into main Oct 5, 2026
2 checks passed
@theodor90
theodor90 deleted the fix/tolerate-new-fields branch October 5, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant