Skip to content

Commit 95ce8e9

Browse files
committed
chore: bump version to 0.2.1
This release fixes compatibility issues with Pydantic v2: - Updated all field validators to use @classmethod decorator - Fixed validator method signatures to work with Pydantic v2 - Improved type annotations and docstrings This patch release ensures the library works correctly with Pydantic v2 after dropping support for Pydantic v1 in version 0.2.0.
1 parent b43e5c2 commit 95ce8e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1294
-506
lines changed

.coveragerc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[run]
22
source = aiowhitebit
3-
omit =
3+
omit =
44
*/tests/*
55
*/venv/*
66
*/setup.py
@@ -12,4 +12,4 @@ exclude_lines =
1212
raise NotImplementedError
1313
if __name__ == .__main__.:
1414
pass
15-
raise ImportError
15+
raise ImportError

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repos:
1212
- id: requirements-txt-fixer
1313

1414
- repo: https://github.com/astral-sh/ruff-pre-commit
15-
rev: v0.11.7
15+
rev: v0.11.8
1616
hooks:
1717
- id: ruff
1818
args: [--fix, --exit-non-zero-on-fix]

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [0.2.1] - 2025-05-03
4+
5+
### Fixed
6+
- Updated field validators to be compatible with Pydantic v2
7+
- Fixed validator decorators to use @classmethod as required by Pydantic v2
8+
39
## [0.2.0] - 2024-07-15
410

511
### Changed

aiowhitebit/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Async Python client for WhiteBit API.
2+
3+
This package provides a comprehensive async client for interacting with the WhiteBit cryptocurrency
4+
exchange API, including public and private endpoints, websocket connections, and webhook handling.
5+
"""
6+
7+
# Version information
8+
__version__ = "0.2.1"

aiowhitebit/clients/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,16 @@
99
get_public_websocket_client,
1010
ws_subscribe_builder,
1111
)
12+
13+
__all__ = [
14+
"PrivateV4Client",
15+
"PublicV1Client",
16+
"PublicV2Client",
17+
"PublicV4Client",
18+
"PublicWebSocketClient",
19+
"SubscribeRequest",
20+
"WebhookDataLoader",
21+
"get_public_websocket_client",
22+
"get_webhook_data_loader",
23+
"ws_subscribe_builder",
24+
]

aiowhitebit/clients/base.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,49 @@
1212

1313

1414
class HTTPClient:
15+
"""Base HTTP client for making API requests.
16+
17+
This class provides the core functionality for making HTTP requests,
18+
managing the client session, and handling rate limiting.
19+
"""
20+
1521
def __init__(self):
22+
"""Initialize the HTTP client.
23+
24+
Sets up an empty session and default rate limiter.
25+
"""
1626
self._session: Optional[aiohttp.ClientSession] = None
1727
self._rate_limiter = Semaphore(100) # Default rate limit
1828

1929
@property
2030
async def session(self) -> aiohttp.ClientSession:
31+
"""Get or create an aiohttp client session.
32+
33+
Returns:
34+
An active aiohttp ClientSession instance.
35+
"""
2136
if self._session is None or self._session.closed:
2237
self._session = aiohttp.ClientSession()
2338
return self._session
2439

2540
async def close(self) -> None:
41+
"""Close the aiohttp client session if it exists and is open."""
2642
if self._session and not self._session.closed:
2743
await self._session.close()
2844
self._session = None
2945

3046
async def get(self, url: str) -> Any:
47+
"""Make a GET request to the specified URL.
48+
49+
Args:
50+
url: The URL to make the request to.
51+
52+
Returns:
53+
The JSON response from the request.
54+
55+
Raises:
56+
WhitebitAPIError: If the response status is not 200.
57+
"""
3158
async with self._rate_limiter:
3259
session = await self.session
3360
async with session.get(url) as response:
@@ -38,17 +65,36 @@ async def get(self, url: str) -> Any:
3865
async def _handle_error_response(self, response: aiohttp.ClientResponse) -> None:
3966
try:
4067
error_data = await response.json()
41-
except:
68+
except Exception:
4269
error_data = await response.text()
4370
raise WhitebitAPIError(response.status, str(error_data))
4471

4572

4673
class BaseClient(HTTPClient):
74+
"""Base client for WhiteBit API endpoints.
75+
76+
This class extends the HTTPClient with WhiteBit-specific functionality
77+
for constructing API URLs and making requests to the API endpoints.
78+
"""
79+
4780
def __init__(self, base_url: str = BASE_URL):
81+
"""Initialize the base client.
82+
83+
Args:
84+
base_url: Base URL for the WhiteBit API. Defaults to the official WhiteBit API URL.
85+
"""
4886
super().__init__()
4987
self.base_url = base_url
5088

5189
def request_url(self, path: str) -> str:
90+
"""Construct the full URL for an API endpoint.
91+
92+
Args:
93+
path: API endpoint path.
94+
95+
Returns:
96+
Full URL for the API endpoint.
97+
"""
5298
return f"{self.base_url}{path}"
5399

54100
async def _make_request(self, path: str, converter: Optional[Callable[[dict], T]] = None) -> T:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
"""Private API clients."""
22

33
from aiowhitebit.clients.private.v4 import PrivateV4Client
4+
5+
__all__ = [
6+
"PrivateV4Client",
7+
]

0 commit comments

Comments
 (0)