Repository navigation
docs: fix resource-doc drift (live-data, portfolio, structured-targets) + LiveDataResource docstring - #358
Conversation
…s) + LiveDataResource docstring Three resource reference pages had drifted from their implementations, and the LiveDataResource.get_typed docstring did not explain that the _typed suffix refers to the legacy URL form rather than to Python typing — readers scanning autocomplete were likely to pick get_typed over get for the wrong reason. docs/resources/live-data.md: corrected three quick-reference endpoint paths to include the /milestone segment and the /batch suffix, and fixed the batch() snippet to iterate the returned list[LiveData] directly (the prior .live_data attribute access raised AttributeError on first use). docs/resources/portfolio.md: removed the stale warning claiming positions_all() does not exist — it shipped in v2.4 (#269) on both sync and async resources. The page now shows the iterator usage and lifts the event_positions caveat from the method docstring, keeping the manual cursor loop as the documented fallback for callers that need the event view. docs/resources/structured-targets.md: rewrote the 404 paragraph to match reality — the resource calls plain _get() and 404 propagates as KalshiNotFoundError; the StructuredTarget | None return reflects the spec-optional envelope field (200 with structured_target=null), not a 404 coalesce. The snippet now uses try/except with the rare soft-not-found branch. kalshi/resources/live_data.py: expanded the get_typed docstring on both sync and async classes to state up front that get_typed and get return the same LiveData with the same annotations, and that the only difference is the URL form. No rename — that would be breaking. Closes #318, #319, #320, #336
Code Review — PR #358: docs: fix resource-doc driftSummary: Docs-only PR fixing four documentation/docstring drift issues. No behavioral changes. Factual Accuracy (verified against implementation)live-data.md ✅
portfolio.md ✅
structured-targets.md ✅
live_data.py docstrings ✅
SuggestionsMinor — structured-targets.md snippet verbosity: from kalshi.errors import KalshiNotFoundError
try:
t = client.structured_targets.get("st_abc")
except KalshiNotFoundError:
print("not found")
t = None
if t is None:
print("soft-not-found (200 with null body)")
else:
print(t.name, t.target_type)Not a blocker — the current form is unambiguous and the comment explains the nested check. Either way works. Minor — portfolio.md version pin: TestingNo tests needed — docs and docstring text only. The PR description correctly notes Overall: Approve. All factual claims verified against the implementation. The corrections are accurate, the rationale in the portfolio note matches the source docstring exactly, and the |
|
Round-2 review addressed in cb6680e:
Deferring as non-blocking: structured-targets.md try/except snippet verbosity — current form is unambiguous, the bot agreed either reading works. |
Code ReviewSummary: Docs-only PR fixing four documentation drift issues across three resource reference pages and one docstring. All changes verified against the live implementation. Accuracy check: all four changes verified correct
IssuesPR description contains a version error The PR body says: "removed the stale claim that The CHANGELOG and the diff itself both say Minor suggestions
The new snippet nests a # In practice, None is only returned if the server responds 200 with
# {"structured_target": null} — extremely rare. Most callers can ignore it.
try:
t = client.structured_targets.get("st_abc")
except KalshiNotFoundError:
print("not found")
else:
print(t.name, t.target_type) # t is None only on server soft-not-foundThis is a minor readability nit — the current version is not wrong. VerdictAll four corrections are accurate and improve the documentation. No behavioral changes. The PR description version error is worth a follow-up note but doesn't block merge. No test changes needed (docs only). Approve with minor notes. |
Summary
Four documentation drift fixes against
kalshi/resources/: three resourcereference pages were out-of-sync with the implementation they document, and
the
LiveDataResource.get_typeddocstring did not explain that the_typedsuffix refers to the legacy URL form, not Python typing.
Issues closed
docs/resources/live-data.md: corrected three quick-reference endpoint paths (/live_data/milestone/{milestone_id},/live_data/batch,/live_data/milestone/{milestone_id}/game_stats) and fixed thebatch()snippet to iterate the returnedlist[LiveData]directly instead of a non-existent.live_dataattribute.docs/resources/portfolio.md: removed the stale claim thatpositions_all()does not exist (it shipped in v2.4 via Polish bundle: REST resource small items (positions *_all(), enum validation, deprecation, list helpers, stale comment) #269) and now documents it with theevent_positionsrationale lifted from the method's docstring.docs/resources/structured-targets.md: rewrote the 404 paragraph to match reality (KalshiNotFoundErroris raised;Noneonly happens on a 200 with{"structured_target": null}) and updated the snippet to a realistictry/exceptshape.kalshi/resources/live_data.py: expanded theget_typeddocstring (sync and async) to explicitly state that_typedrefers to the legacy URL form, not type safety, so autocomplete readers do not pick it overget.Behavioral changes
None. Docs and docstring text only.
Tests
None — docs-only PR.
ruff checkandmypypass onkalshi/resources/live_data.py.Source
Round-3 independent audit closure plan, wave W0.