feat(clients): add typed overloads for mutually-exclusive lookup args#126
Open
naruto11eth wants to merge 3 commits into
Open
feat(clients): add typed overloads for mutually-exclusive lookup args#126naruto11eth wants to merge 3 commits into
naruto11eth wants to merge 3 commits into
Conversation
Add keyword-only `@overload` stubs so "exactly one of id/slug/url" (id/slug for tags) is visible to the type checker on `get_market`/`get_event`/`get_tag`, across the sync and async public and secure clients. `get_tag`'s `include_template` is offered only on the id overload, mirroring the runtime guard. Impl bodies and the runtime "exactly one" validation are unchanged — overloads are typing-only guidance.
Add keyword-only `@overload` stubs so "exactly one of condition_id/market_id/position_id" is visible to the type checker on `SecureClient.redeem_positions` and its async twin. Impl body and the runtime sum-check are unchanged.
…right The new `redeem_positions` overloads correctly make the deliberate two-selector and zero-selector calls (which exercise the runtime "exactly one" guard) static type errors. Add a narrow `# pyright: ignore[reportCallIssue]` on each so the static-checks gate passes while the runtime-validation tests stay.
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.
Makes "exactly one of " visible to the type checker for the lookup methods that take all-optional keyword args, while keeping
get_market(id=...)ergonomics, the public method names, and the existing runtime validation (DEV-115).Adds keyword-only
@overloadstubs (one per selector) above each method's unchanged impl — mirroring the existingestimate_market_price/create_market_orderpattern. Purely additive typing; impl bodies and the runtime "exactly one" guards are untouched.get_market/get_event— exactly one ofid|slug|urlget_tag— exactly one ofid|slug(include_templateoffered only on theidoverload, matching the runtime guard)redeem_positions— exactly one ofcondition_id|market_id|position_id. Note: the ticket mentionedcondition_id/market_id, but the method actually takes a third selector (position_id, for combo positions), so this is a 3-way overload.Applied across the sync + async public and secure clients (
get_*on all four;redeem_positionson the two secure clients).Verified: pyright (strict) now reports an error for zero-selector and multi-selector calls (and
get_tag(slug=..., include_template=...)), while every valid single-selector shape type-checks clean. Runtime behavior unchanged — full unit suite green; ruff + pyright strict clean.Refs DEV-115
Note
Low Risk
Purely additive static typing and test pyright suppressions; no changes to method implementations or runtime validation.
Overview
Adds keyword-only
@overloadstubs on sync/async public and secure clients so pyright enforces exactly one lookup selector at compile time, matching existing runtime guards (DEV-115).get_market/get_event: one ofid,slug, orurl.get_tag: one ofidorslug;include_templateis typed only on theidoverload.redeem_positions(secure clients only): one ofcondition_id,market_id, orposition_id.Implementation bodies are unchanged—typing only, same pattern as
estimate_market_price/create_market_order. Unit tests that deliberately call invalid selector combinations now use# pyright: ignore[reportCallIssue]so strict checking stays green.Reviewed by Cursor Bugbot for commit c9465b8. Bugbot is set up for automated code reviews on this repo. Configure here.