Skip to content

fix(python): complete type stubs for string enums and the util submodule#887

Merged
userFRM merged 1 commit into
mainfrom
fix/round11-python
Jun 17, 2026
Merged

fix(python): complete type stubs for string enums and the util submodule#887
userFRM merged 1 commit into
mainfrom
fix/round11-python

Conversation

@userFRM

@userFRM userFRM commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Several runtime-exported objects resolved only through the module-level __getattr__ fallback to Any, so mypy users got no typing for them. This completes the typed surface so an institutional-grade typed SDK actually type-checks end to end.

What changed:

  • Added explicit class declarations for the six string-valued parameter enums (Right, Venue, Interval, RateType, RequestType, Version). Each carries its exact members, the value accessor, and the __str__ / __repr__ / __eq__ / __hash__ surface. Member names and tokens were read straight from the enum registration so they match runtime byte-for-byte.
  • Shipped a util.pyi stub for the thetadatadx.util submodule, declaring all fourteen public lookup and conversion functions (condition_name, exchange_symbol, calendar_status_name, timestamp_ms, the sequence re-encoders, and the rest) with their real signatures and return types. Maturin already merges everything under python/thetadatadx/ into the wheel, so the new stub packages alongside __init__.pyi and py.typed with no manifest change.
  • Added the missing __bool__ and __repr__ to FlatFileRowList.

Verification:

  • Built the extension into a scratch venv and ran mypy.stubtest with the CI flags (--allowlist sdks/python/stubtest_allowlist.txt --ignore-missing-stub --ignore-disjoint-bases --ignore-positional-only). The newly declared symbols match the runtime exactly, with no new discrepancies; the remaining unstubbed surface is the generator-emitted builders and tick wrappers the allowlist already documents.
  • python3 scripts/check_binding_parity.py stays clean.

🤖 Generated with Claude Code

The type-stub surface left several runtime exports resolving only through the module-level `__getattr__` fallback to `Any`, so mypy users typing against `Interval.M_1`, `Right.CALL`, or the `thetadatadx.util` lookups got no checking at all.

Add explicit class declarations for the six string-valued parameter enums (`Right`, `Venue`, `Interval`, `RateType`, `RequestType`, `Version`) with their exact members, the `value` accessor, and the `__str__` / `__repr__` / `__eq__` / `__hash__` surface. Ship a `util.pyi` for the `thetadatadx.util` submodule declaring all fourteen public lookup and conversion functions with their real signatures and return types. Add the missing `__bool__` and `__repr__` to `FlatFileRowList`.

Verified with `mypy.stubtest` against the built extension under the repo's CI flags: the newly declared symbols match the runtime exactly, with no new discrepancies. The cross-binding parity gate stays clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@userFRM userFRM merged commit 76fbda2 into main Jun 17, 2026
22 checks passed
@userFRM userFRM deleted the fix/round11-python branch June 17, 2026 21:23
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.

2 participants