fix(client): tighten Perps request typing#139
Merged
Conversation
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.
Summary
PerpsOrderRequestso GTC price and IOC/FOK post-only constraints are visible to pyrightVerification
uv run ruff check .uv run ruff format --check .uv run pyrightuv run pytest -m "not integration"Stacked on #133.
Note
Low Risk
Mostly type hints and documentation; the only behavioral tweak is rejecting post_only on non-gtc place_order paths, which matches documented constraints.
Overview
Tightens static typing and docs for the Perps async surface without changing wire behavior for valid callers.
PerpsOrderRequestnow uses constructor overloads so pyright requirespriceforgtcand disallowspost_onlyonioc/fok.PerpsSession.cancel_orderandcancel_ordersget the same pattern soorder_idvsclient_order_id(and list variants) are mutually exclusive at type-check time.place_orderbuilds the request in agtcvs non-gtcbranch and raisesUserInputErrorifpost_onlyis used outsidegtc(runtime guard aligned with types).Docstrings on
PerpsSession,AsyncPublicClient, andAsyncSecureClientPerps helpers are expanded (pagination,depth, sessionArgs, depositmetadata, etc.) to match the TypeScript SDK wording.Adds
tests/unit/test_perps_typing.py(pyrightassert_typeexamples) and adjuststest_perps_trading_commandsfor the newPerpsOrderRequestconstructor.Reviewed by Cursor Bugbot for commit c63abf0. Bugbot is set up for automated code reviews on this repo. Configure here.