Skip to content

fix: annotate get_fundamentals_data return type as dict (#71)#72

Open
alexpipipi wants to merge 2 commits into
mainfrom
fix/fundamentals-return-type
Open

fix: annotate get_fundamentals_data return type as dict (#71)#72
alexpipipi wants to merge 2 commits into
mainfrom
fix/fundamentals-return-type

Conversation

@alexpipipi

@alexpipipi alexpipipi commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Closes #71 (reported by @AnthonyTedde).

/api/fundamentals/{ticker} returns a JSON object, but get_fundamentals_data (and get_fundamentals_data_v1_1, which has the same bug) were annotated -> list. This produces misleading IDE hints and type-checker errors.

Change

  • get_fundamentals_data and get_fundamentals_data_v1_1: -> list-> dict
  • Added a regression test asserting both return annotations are dict

Verification

  • Live API call through the library: get_fundamentals_data('AAPL.US') returns dict with keys General, Highlights, Valuation, ...
  • pytest: ✅ 66 passed

Update

  • Documented that a narrowing filter (e.g. General::Code) can reshape the response to a scalar value; the -> dict annotation reflects the common unfiltered / top-level-section case.

alexpipipi and others added 2 commits June 16, 2026 14:24
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 sanchescom left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

get_fundamentals_data should return dict, not list

2 participants