Repository navigation
fix(fmp-py): type DynamicObject getters as dict[str, Any] in stubs - #410
Merged
Merged
Conversation
The getters backed by `DynamicObject` previously surfaced in the stubs as bare `typing.Any`, hiding the fact that they always return a JSON object. This made callers lose type information on `additional_columns`, `data`, and `sections` fields. **Code generation:** * Emit `override_return_type` with `builtins.dict[builtins.str, typing.Any]` for object passthrough getters, including the optional variant. * Add unit tests covering the number, object, and value getter stubs. **Model stubs and sources:** * Regenerate the `.pyi` stubs so the four object getters now read as `dict[str, Any]` instead of `Any`. * Annotate the corresponding Rust getters with the matching stub override. **Tests:** * Verify the former `Any` JSON-object fields are stubbed as str-keyed dicts and read back as real `dict` instances. * Extend the type-check contract to cover the new `sections` and segment `data` return types. close #409
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.
The getters backed by
DynamicObjectpreviously surfaced in the stubs asbare
typing.Any, hiding the fact that they always return a JSON object.This made callers lose type information on
additional_columns,data,and
sectionsfields.Code generation:
override_return_typewithbuiltins.dict[builtins.str, typing.Any]for object passthrough getters, including the optional variant.
Model stubs and sources:
.pyistubs so the four object getters now read asdict[str, Any]instead ofAny.Tests:
AnyJSON-object fields are stubbed as str-keyed dictsand read back as real
dictinstances.sectionsand segmentdatareturn types.close #409