Skip to content

feat: export enum constants + Literal type hints (#4)#136

Merged
martinkersner merged 1 commit into
mainfrom
feat/export-enums-literals
Jul 3, 2026
Merged

feat: export enum constants + Literal type hints (#4)#136
martinkersner merged 1 commit into
mainfrom
feat/export-enums-literals

Conversation

@martinkersner

Copy link
Copy Markdown
Member

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: add Literal aliases Market (spot/futures), Interval (the 8 supported intervals), SortOrder (asc/desc).
  • datamaxi/__init__.py: re-export SPOT, FUTURES, USD, ASC, DESC, INTERVAL_*, SUPPORTED_INTERVALS, and the three aliases; add __all__.
  • Annotate market/interval/sort params across the client surface (cex candle/ticker, funding_rate, index_price, open_interest, liquidation, cex_announcement, premium, telegram) with the aliases.

Literal is 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 skipped
  • Import smoke test: from datamaxi import SPOT, FUTURES, Market, Interval, SortOrder, SUPPORTED_INTERVALS OK
  • black + flake8 clean across datamaxi/

Known failures

None.

Notes

_endpoints.py (codegen'd upstream) is untouched. premium.source_market/target_market annotated as Optional[Market] on the assumption they're the same spot/futures enum used elsewhere — flag if that's wrong.

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.
@martinkersner martinkersner merged commit 558278c into main Jul 3, 2026
5 checks passed
@martinkersner martinkersner deleted the feat/export-enums-literals branch July 3, 2026 03:16
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