Skip to content

feat(clients): add typed overloads for mutually-exclusive lookup args#126

Open
naruto11eth wants to merge 3 commits into
mainfrom
feature/dev-115-typed-mutually-exclusive-shapes
Open

feat(clients): add typed overloads for mutually-exclusive lookup args#126
naruto11eth wants to merge 3 commits into
mainfrom
feature/dev-115-typed-mutually-exclusive-shapes

Conversation

@naruto11eth

@naruto11eth naruto11eth commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

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 @overload stubs (one per selector) above each method's unchanged impl — mirroring the existing estimate_market_price / create_market_order pattern. Purely additive typing; impl bodies and the runtime "exactly one" guards are untouched.

  • get_market / get_event — exactly one of id | slug | url
  • get_tag — exactly one of id | slug (include_template offered only on the id overload, matching the runtime guard)
  • redeem_positions — exactly one of condition_id | market_id | position_id. Note: the ticket mentioned condition_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_positions on 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 @overload stubs 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 of id, slug, or url. get_tag: one of id or slug; include_template is typed only on the id overload. redeem_positions (secure clients only): one of condition_id, market_id, or position_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.

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.
@naruto11eth naruto11eth requested a review from cesarenaldi June 27, 2026 02:14
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.

1 participant