Repository navigation
polish: cursor guard O(1); batch bytes path; bench scripts; close terminality; env isolation; from_env test - #236
Conversation
…minality; env isolation; from_env test - _list_all cursor-loop guard switched from set[str] to single last_cursor: O(1) memory. - Resource _base: new _post_json / _delete_with_body_json bytes helpers. Batch order paths use model_dump_json + httpx content= to skip one full dict-walk pass per call. - Transport.request: optional content + headers kwargs (errors if json+content both set). - KalshiAuth.close() is now terminal: subsequent sign_request_async raises RuntimeError instead of silently respawning the executor (pairs with #210 ownership tracking). - tests/integration/conftest.py: env-bridging moved from import-time mutation to a session-scoped fixture with monkeypatch. - tests/test_auth.py: KALSHI_PRIVATE_KEY takes precedence over KALSHI_PRIVATE_KEY_PATH in from_env / try_from_env (pinning current behavior). - New scripts/bench_ws_recv.py, scripts/bench_orderbook_delta.py, scripts/bench_request_hot_path.py for perf regression visibility. Closes #223 Refs #224
Code Review — PR #236OverviewWave 3-B delivers 6 focused polish items: O(1) cursor guard, batch-ops bytes path, bench scripts, Issues1. Cursor guard now allows multi-step cycles (behavioral change)File: The switch from A 2.
|
Wave 3-B of audit umbrella. 6 P4 polish items.
Changes
_list_allcursor-loop guard switched fromset[str]to singlelast_cursor(O(1) memory) in both sync and async._post_json/_delete_with_body_jsonbytes helpers;batch_create/batch_cancelroute through them viamodel_dump_json + content=, skipping one full dict-walk pass per call. Transport gainedcontent/headerskwargs with mutual exclusion againstjson=.scripts/bench_ws_recv.py,scripts/bench_orderbook_delta.py,scripts/bench_request_hot_path.pyfor perf-regression visibility (all smoke-tested).KALSHI_PRIVATE_KEYprecedence overKALSHI_PRIVATE_KEY_PATHpinned viafrom_env+try_from_envtests verifying signature against the inline key.tests/integration/conftest.pyenv-bridging moved from import-timeos.environmutation to a session-scoped monkeypatch fixture (test isolation fix).KalshiAuth.close()is now terminal —_closedflag set,_get_sign_executorraisesRuntimeErrorinstead of silently respawning (pairs with Auth: KalshiClient.close() shouldn't shut down externally-provided KalshiAuth executor #210 ownership tracking).436 unit tests green. ruff clean.
Closes #223
Refs #224, Refs #210