mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-20 15:24:21 +01:00
Apply black to all python files (bfxapi/**/*.py).
This commit is contained in:
@@ -2,15 +2,16 @@ import json
|
||||
from decimal import Decimal
|
||||
from typing import Any, Dict, List, Union
|
||||
|
||||
_ExtJSON = Union[Dict[str, "_ExtJSON"], List["_ExtJSON"], \
|
||||
bool, int, float, str, Decimal, None]
|
||||
_ExtJSON = Union[
|
||||
Dict[str, "_ExtJSON"], List["_ExtJSON"], bool, int, float, str, Decimal, None
|
||||
]
|
||||
|
||||
_StrictJSON = Union[Dict[str, "_StrictJSON"], List["_StrictJSON"], int, str, None]
|
||||
|
||||
_StrictJSON = Union[Dict[str, "_StrictJSON"], List["_StrictJSON"], \
|
||||
int, str, None]
|
||||
|
||||
def _clear(dictionary: Dict[str, Any]) -> Dict[str, Any]:
|
||||
return { key: value for key, value in dictionary.items() \
|
||||
if value is not None }
|
||||
return {key: value for key, value in dictionary.items() if value is not None}
|
||||
|
||||
|
||||
def _adapter(data: _ExtJSON) -> _StrictJSON:
|
||||
if isinstance(data, bool):
|
||||
@@ -21,12 +22,13 @@ def _adapter(data: _ExtJSON) -> _StrictJSON:
|
||||
return format(data, "f")
|
||||
|
||||
if isinstance(data, list):
|
||||
return [ _adapter(sub_data) for sub_data in data ]
|
||||
return [_adapter(sub_data) for sub_data in data]
|
||||
if isinstance(data, dict):
|
||||
return _clear({ key: _adapter(value) for key, value in data.items() })
|
||||
return _clear({key: _adapter(value) for key, value in data.items()})
|
||||
|
||||
return data
|
||||
|
||||
|
||||
class JSONEncoder(json.JSONEncoder):
|
||||
def encode(self, o: _ExtJSON) -> str:
|
||||
return super().encode(_adapter(o))
|
||||
|
||||
Reference in New Issue
Block a user