Skip to content

fix(fmp-py): type DynamicObject getters as dict[str, Any] in stubs - #410

Merged
benbenbang merged 1 commit into
mainfrom
fix/stub-dynamic-object
Oct 2, 2026
Merged

benbenbang merged 1 commit into
mainfrom
fix/stub-dynamic-object

Conversation

@benbenbang

Copy link
Copy Markdown
Member

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

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
@benbenbang
benbenbang enabled auto-merge (rebase) October 2, 2026 17:42
@github-actions github-actions Bot added the enhancement New feature or request label Oct 2, 2026
@benbenbang
benbenbang merged commit 45d609a into main Oct 2, 2026
9 checks passed
@benbenbang
benbenbang deleted the fix/stub-dynamic-object branch October 2, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(fmp-py): type DynamicObject getters as dict[str, Any] in stubs

1 participant