feat: export enum constants + Literal type hints (#4)#136
Merged
Conversation
Add Market/Interval/SortOrder Literal aliases in lib/constants.py and re-export them plus SPOT/FUTURES/USD/ASC/DESC/INTERVAL_*/SUPPORTED_INTERVALS from the top-level datamaxi package (with __all__). Annotate the market/interval/sort params across the client surface with these aliases. Literal is hint-only (not runtime-enforced), so bare strings still work; this only adds IDE/mypy checking. No behavior change.
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.
Summary
PR 2 of 4 from the SDK-structure review. Makes the enumerable string params (
market,interval,sort) checkable before runtime and gives users importable constants instead of bare magic strings.lib/constants.py: addLiteralaliasesMarket(spot/futures),Interval(the 8 supported intervals),SortOrder(asc/desc).datamaxi/__init__.py: re-exportSPOT,FUTURES,USD,ASC,DESC,INTERVAL_*,SUPPORTED_INTERVALS, and the three aliases; add__all__.market/interval/sortparams across the client surface (cex candle/ticker, funding_rate, index_price, open_interest, liquidation, cex_announcement, premium, telegram) with the aliases.Literalis hint-only — not runtime-enforced — so callers passing bare strings (market="spot") keep working exactly as before. This is purely additive: IDE autocomplete + mypy checking, zero behavior change.Tests
pytest -m "not integration": 134 passed, 11 skippedfrom datamaxi import SPOT, FUTURES, Market, Interval, SortOrder, SUPPORTED_INTERVALSOKdatamaxi/Known failures
None.
Notes
_endpoints.py(codegen'd upstream) is untouched.premium.source_market/target_marketannotated asOptional[Market]on the assumption they're the same spot/futures enum used elsewhere — flag if that's wrong.