[pull] main from fern-api:main#756
Merged
Merged
Conversation
…level contexts (#14154) * fix(python): simplify parse_sse_obj to always use data-level discrimination Remove runtime heuristics that tried to detect data-vs-event discrimination at runtime. When the discriminant field name collided with an SSE envelope field (e.g., 'event'), the heuristic incorrectly routed to the event-level path. Now parse_sse_obj always parses sse.data as JSON and lets Pydantic handle the discriminator. Protocol-level discrimination will be handled at code-generation time in a follow-up PR. Co-Authored-By: Deep Singhvi <deep@buildwithfern.com> * fix: remove unused imports flagged by ruff in pydantic v1 variant Co-Authored-By: Deep Singhvi <deep@buildwithfern.com> * feat(python): add protocol-level SSE discrimination at code-generation time For unions with discriminator_context == 'protocol', the generator now emits an if/elif chain that dispatches on _sse.event and parses each variant's data payload into its concrete type via parse_obj_as. Data-level discrimination (the default) continues to use parse_sse_obj. Co-Authored-By: Deep Singhvi <deep@buildwithfern.com> * fix: use NamedType instead of DeclaredTypeName for TypeReference.factory.named() Co-Authored-By: Deep Singhvi <deep@buildwithfern.com> * fix(python): use get_wire_value helper for protocol SSE discriminant The merge with main introduced a new helper get_wire_value(name_or_str) since discriminant_value is now Union[str, NameAndWireValue]. Update the protocol discriminator extraction to go through this helper. Also regenerate Python SDK seed fixtures missed by earlier regeneration. Co-Authored-By: Deep Singhvi <deep@buildwithfern.com> * chore: regenerate SSE seed fixtures after merge Co-Authored-By: ryanstep <ryanstep@umich.edu> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: ryanstep <ryanstep@umich.edu> Co-authored-by: Fern Support <126544928+fern-support@users.noreply.github.com>
Co-authored-by: Ryan-Amirthan <105958906+Ryan-Amirthan@users.noreply.github.com>
Co-authored-by: dsinghvi <10870189+dsinghvi@users.noreply.github.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )