Skip to content

Commit 5555d3d

Browse files
committed
Remove standalone Telegram/Naver clients from public API
Drop top-level re-exports + __all__ entries for Telegram/Naver (datamaxi) and AsyncTelegram/AsyncNaver (datamaxi.aio); bind aio mount imports privately so the names aren't importable. Impl classes kept, reachable only via maxi.telegram / maxi.naver. Tests source the classes from their package modules / mounts. Closes #188
1 parent a5f6076 commit 5555d3d

6 files changed

Lines changed: 34 additions & 24 deletions

File tree

‎datamaxi/__init__.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
from datamaxi.resources import Datamaxi # noqa: F401
2-
from datamaxi.telegram import Telegram # noqa: F401
3-
from datamaxi.naver import Naver # noqa: F401
42
from datamaxi.lib.constants import ( # noqa: F401
53
SPOT,
64
FUTURES,
@@ -46,8 +44,6 @@
4644

4745
__all__ = [
4846
"Datamaxi",
49-
"Telegram",
50-
"Naver",
5147
"SPOT",
5248
"FUTURES",
5349
"USD",

‎datamaxi/aio/__init__.py‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
1717
Mirrors the full sync surface (``cex.*``, ``funding_rate``, ``forex``,
1818
``premium``, ``liquidation``, ``open_interest``, ``margin_borrow``,
19-
``index_price``, ``telegram``, ``naver``). The standalone
20-
``AsyncTelegram`` / ``AsyncNaver`` classes stay exported for back-compat.
21-
Reuses
22-
the sync client's endpoint resolution and error handling (``datamaxi._dispatch``)
23-
and the shared DataFrame / ResponseMeta helpers, so the two clients can't drift
24-
on request building or error semantics.
19+
``index_price``, ``telegram``, ``naver``). Reuses the sync client's endpoint
20+
resolution and error handling (``datamaxi._dispatch``) and the shared DataFrame
21+
/ ResponseMeta helpers, so the two clients can't drift on request building or
22+
error semantics.
2523
"""
2624

2725
from typing import Any
@@ -45,8 +43,8 @@
4543
from datamaxi.aio.open_interest import AsyncOpenInterest
4644
from datamaxi.aio.margin_borrow import AsyncMarginBorrow
4745
from datamaxi.aio.index_price import AsyncIndexPrice
48-
from datamaxi.aio.telegram import AsyncTelegram
49-
from datamaxi.aio.naver import AsyncNaver
46+
from datamaxi.aio.telegram import AsyncTelegram as _AsyncTelegram
47+
from datamaxi.aio.naver import AsyncNaver as _AsyncNaver
5048

5149

5250
class AsyncDatamaxi:
@@ -70,8 +68,8 @@ def __init__(self, api_key=None, **kwargs: Any):
7068
self.open_interest = AsyncOpenInterest(api)
7169
self.margin_borrow = AsyncMarginBorrow(api)
7270
self.index_price = AsyncIndexPrice(api)
73-
self.telegram = AsyncTelegram(api=api)
74-
self.naver = AsyncNaver(api=api)
71+
self.telegram = _AsyncTelegram(api=api)
72+
self.naver = _AsyncNaver(api=api)
7573

7674
async def aclose(self):
7775
await self._api.aclose()
@@ -90,8 +88,6 @@ def __repr__(self):
9088

9189
__all__ = [
9290
"AsyncDatamaxi",
93-
"AsyncTelegram",
94-
"AsyncNaver",
9591
"AsyncAPI",
9692
"AsyncResource",
9793
"AsyncCex",

‎tests/conftest.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import pytest
1111

12-
from datamaxi import Datamaxi, Telegram, Naver
12+
from datamaxi import Datamaxi
1313
from datamaxi.api import API
1414
from datamaxi.error import ServerError
1515

@@ -76,11 +76,11 @@ def datamaxi():
7676

7777
@pytest.fixture(scope="module")
7878
def telegram():
79-
"""Create Telegram client for live tests."""
80-
return Telegram(api_key=API_KEY, base_url=BASE_URL, timeout=TIMEOUT)
79+
"""Telegram resource (mounted) for live tests."""
80+
return Datamaxi(api_key=API_KEY, base_url=BASE_URL, timeout=TIMEOUT).telegram
8181

8282

8383
@pytest.fixture(scope="module")
8484
def naver():
85-
"""Create Naver client for live tests."""
86-
return Naver(api_key=API_KEY, base_url=BASE_URL, timeout=TIMEOUT)
85+
"""Naver resource (mounted) for live tests."""
86+
return Datamaxi(api_key=API_KEY, base_url=BASE_URL, timeout=TIMEOUT).naver

‎tests/test_async_resources.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
httpx = pytest.importorskip("httpx")
1313

14-
from datamaxi.aio import AsyncDatamaxi, AsyncTelegram, AsyncNaver # noqa: E402
14+
from datamaxi.aio import AsyncDatamaxi # noqa: E402
15+
from datamaxi.aio.telegram import AsyncTelegram # noqa: E402
16+
from datamaxi.aio.naver import AsyncNaver # noqa: E402
1517

1618
BASE_URL = "https://api.datamaxiplus.com"
1719

@@ -171,6 +173,13 @@ async def run():
171173
assert _run(run()) == _CHANNELS
172174

173175

176+
def test_standalone_async_clients_not_top_level_importable():
177+
import datamaxi.aio
178+
179+
assert not hasattr(datamaxi.aio, "AsyncTelegram")
180+
assert not hasattr(datamaxi.aio, "AsyncNaver")
181+
182+
174183
def test_async_telegram_naver_mounted_reuse_shared_session():
175184
c = _dm()
176185
assert isinstance(c.telegram, AsyncTelegram)

‎tests/test_naver.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import pytest
77
from urllib.parse import urlparse, parse_qs
88

9-
from datamaxi import Datamaxi, Naver
9+
from datamaxi import Datamaxi
10+
from datamaxi.naver import Naver
1011
from datamaxi.error import ClientError, ServerError
1112
from tests.util import mock_http_response
1213

‎tests/test_telegram.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import pytest
66
from urllib.parse import urlparse, parse_qs
77

8-
from datamaxi import Datamaxi, Telegram
8+
from datamaxi import Datamaxi
9+
from datamaxi.telegram import Telegram
910
from datamaxi.error import ClientError, ServerError
1011
from tests.util import mock_http_response
1112

@@ -125,3 +126,10 @@ def test_telegram_mounted_messages_work():
125126
res, next_request = maxi.telegram.messages(channel_name="alpha")
126127
assert res == _MESSAGES
127128
assert callable(next_request)
129+
130+
131+
def test_standalone_clients_not_top_level_importable():
132+
import datamaxi
133+
134+
assert not hasattr(datamaxi, "Telegram")
135+
assert not hasattr(datamaxi, "Naver")

0 commit comments

Comments
 (0)