fix: annotate get_fundamentals_data return type as dict (#71)#72
Open
alexpipipi wants to merge 2 commits into
Open
fix: annotate get_fundamentals_data return type as dict (#71)#72alexpipipi wants to merge 2 commits into
alexpipipi wants to merge 2 commits into
Conversation
The /api/fundamentals/{ticker} endpoint returns a JSON object (keys like
General, Highlights, Valuation, ...), but get_fundamentals_data and
get_fundamentals_data_v1_1 were annotated `-> list`, producing misleading
type hints and type-checker errors for users.
Changed both annotations to `-> dict` and added a regression test asserting
the return annotation. Verified against the live API: AAPL.US fundamentals
returns a dict.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…pe (#71) Follow-up to PR #72 review (Codex GPT-5.4 + Gemini Pro both flagged that -> dict is not universal): document that a narrowing filter (e.g. General::Code) reshapes the response to a scalar/inner value, so -> dict reflects the common unfiltered/top-level case. Annotation kept as dict (a strict improvement over the previous, incorrect -> list). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sanchescom
requested changes
Jun 19, 2026
There was a problem hiding this comment.
Passing filter changes the response shape, so dict is wrong. The real type is dict, str, or list (filter="General::Code" returns "AAPL", a string). Calling .get on that throws AttributeError, and mypy/pyright stay silent since they read the annotation, not the docstring. Change it to Any in both methods, fix the test, then merge.
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.
Closes #71 (reported by @AnthonyTedde).
/api/fundamentals/{ticker}returns a JSON object, butget_fundamentals_data(andget_fundamentals_data_v1_1, which has the same bug) were annotated-> list. This produces misleading IDE hints and type-checker errors.Change
get_fundamentals_dataandget_fundamentals_data_v1_1:-> list→-> dictdictVerification
get_fundamentals_data('AAPL.US')returnsdictwith keysGeneral, Highlights, Valuation, ...pytest: ✅ 66 passedUpdate
filter(e.g.General::Code) can reshape the response to a scalar value; the-> dictannotation reflects the common unfiltered / top-level-section case.