mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-20 07:14:20 +01:00
Rewrite bfxapi/rest/_Requests.py with type hinting. Add None values erasement in bfxapi/utils/JSONEncoder.py. Update code with new improvements.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
from typing import List, Dict, Union, Optional, Any, TypedDict, Generic, TypeVar, cast
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from .labeler import _Type, _Serializer
|
||||
|
||||
T = TypeVar("T")
|
||||
@@ -19,10 +17,10 @@ class Notification(_Type, Generic[T]):
|
||||
class _Notification(_Serializer, Generic[T]):
|
||||
__LABELS = [ "mts", "type", "message_id", "_PLACEHOLDER", "notify_info", "code", "status", "text" ]
|
||||
|
||||
def __init__(self, serializer: Optional[_Serializer] = None, iterate: bool = False):
|
||||
def __init__(self, serializer: Optional[_Serializer] = None, is_iterable: bool = False):
|
||||
super().__init__("Notification", Notification, _Notification.__LABELS, IGNORE = [ "_PLACEHOLDER" ])
|
||||
|
||||
self.serializer, self.iterate = serializer, iterate
|
||||
self.serializer, self.is_iterable = serializer, is_iterable
|
||||
|
||||
def parse(self, *values: Any, skip: Optional[List[str]] = None) -> Notification[T]:
|
||||
notification = cast(Notification[T], Notification(**dict(self._serialize(*values))))
|
||||
@@ -30,7 +28,7 @@ class _Notification(_Serializer, Generic[T]):
|
||||
if isinstance(self.serializer, _Serializer):
|
||||
NOTIFY_INFO = cast(List[Any], notification.notify_info)
|
||||
|
||||
if self.iterate == False:
|
||||
if self.is_iterable == False:
|
||||
if len(NOTIFY_INFO) == 1 and isinstance(NOTIFY_INFO[0], list):
|
||||
NOTIFY_INFO = NOTIFY_INFO[0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user