Skip to content

fix: correct type hints that disagree with the API - #14

Draft
chipkent wants to merge 1 commit into
masterfrom
fix/type-hints
Draft

chipkent wants to merge 1 commit into
masterfrom
fix/type-hints

Conversation

@chipkent

@chipkent chipkent commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Preview only. This is a draft in the fork showing the exact text of the PR planned for massive-com/client-python. It will be closed, not merged, once the upstream PR is opened.

Fixes #<issue: F4a>
Fixes massive-com#728 (get_previous_close_agg return type).

Some type hints describe values the API never sends or returns, so correct code fails type checking.

Hint Was Now
CryptoQuote.bid_price, ask_price, ask_size Optional[int] Optional[float] (XQ sends "bp": 33052.79, "as": 0.601)
IndexValue.timestamp Optional[str] Optional[int] (Unix ms)
get_previous_close_agg() returns PreviousCloseAgg List[PreviousCloseAgg]
list_treasury_yields(), list_short_interest(), list_short_volume(), vx.list_ipos() return List[...] Iterator[...]
list_tickers(cusip=...) Optional[int] Optional[Union[int, str]]
  • cusip is widened, not changed: an int still type-checks, and the docstring recommends a string, since CUSIPs are alphanumeric and keep leading zeros ("037833100").
  • Only annotations and docstrings change. Runtime behavior is the same.
  • Tests: test_get_previous_close_agg now asserts the result is a list, and a new test checks that the four list_* methods return a lazy iterator.

Several hints describe values the API never sends or returns:

- CryptoQuote.bid_price, ask_price and ask_size were int; XQ sends
  fractional numbers ("bp": 33052.79, "as": 0.601). They are float.
- IndexValue.timestamp was str; V sends integer Unix milliseconds.
- list_tickers(cusip=...) accepted only int. The API treats a CUSIP as a
  string: it is alphanumeric, and leading zeros matter ("037833100").
  The hint now accepts str as well as int, so existing callers keep
  type-checking, and the docstring recommends a string.
- get_previous_close_agg() was annotated as returning one
  PreviousCloseAgg, but it returns the "results" array as a list.
- list_treasury_yields(), list_short_interest(), list_short_volume() and
  list_ipos() were annotated as returning a List, but like every other
  list_* method they return a paginating iterator.

Hints that are imprecise but still admit every value the API sends, such
as integer timestamps hinted as float, are left alone: narrowing them
would gain little and could break callers that type-check today.

Only annotations and docstrings change; runtime behaviour is the same.
The tests pin the runtime types the corrected REST hints now describe.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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.

typing bug on get agg

1 participant