fix(python): complete type stubs for string enums and the util submodule#887
Merged
Conversation
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>
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.
Several runtime-exported objects resolved only through the module-level
__getattr__fallback toAny, 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:
Right,Venue,Interval,RateType,RequestType,Version). Each carries its exact members, thevalueaccessor, 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.util.pyistub for thethetadatadx.utilsubmodule, 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 underpython/thetadatadx/into the wheel, so the new stub packages alongside__init__.pyiandpy.typedwith no manifest change.__bool__and__repr__toFlatFileRowList.Verification:
mypy.stubtestwith 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.pystays clean.🤖 Generated with Claude Code