trd-utils 0.0.47__tar.gz → 0.0.48__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of trd-utils might be problematic. Click here for more details.

Files changed (42) hide show
  1. {trd_utils-0.0.47 → trd_utils-0.0.48}/PKG-INFO +1 -1
  2. {trd_utils-0.0.47 → trd_utils-0.0.48}/pyproject.toml +1 -1
  3. trd_utils-0.0.48/trd_utils/__init__.py +3 -0
  4. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/types_helper/base_model.py +11 -4
  5. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/types_helper/utils.py +12 -0
  6. trd_utils-0.0.47/trd_utils/__init__.py +0 -3
  7. {trd_utils-0.0.47 → trd_utils-0.0.48}/LICENSE +0 -0
  8. {trd_utils-0.0.47 → trd_utils-0.0.48}/README.md +0 -0
  9. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/cipher/__init__.py +0 -0
  10. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/common_utils/float_utils.py +0 -0
  11. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/common_utils/wallet_utils.py +0 -0
  12. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/date_utils/__init__.py +0 -0
  13. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/date_utils/datetime_helpers.py +0 -0
  14. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/README.md +0 -0
  15. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/__init__.py +0 -0
  16. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/base_types.py +0 -0
  17. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/blofin/__init__.py +0 -0
  18. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/blofin/blofin_client.py +0 -0
  19. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/blofin/blofin_types.py +0 -0
  20. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/bx_ultra/__init__.py +0 -0
  21. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/bx_ultra/bx_types.py +0 -0
  22. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/bx_ultra/bx_ultra_client.py +0 -0
  23. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/bx_ultra/bx_utils.py +0 -0
  24. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/errors.py +0 -0
  25. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/exchange_base.py +0 -0
  26. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/hyperliquid/README.md +0 -0
  27. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/hyperliquid/__init__.py +0 -0
  28. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/hyperliquid/hyperliquid_client.py +0 -0
  29. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/hyperliquid/hyperliquid_types.py +0 -0
  30. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/okx/__init__.py +0 -0
  31. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/okx/okx_client.py +0 -0
  32. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/okx/okx_types.py +0 -0
  33. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/exchanges/price_fetcher.py +0 -0
  34. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/html_utils/__init__.py +0 -0
  35. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/html_utils/html_formats.py +0 -0
  36. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/tradingview/__init__.py +0 -0
  37. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/tradingview/tradingview_client.py +0 -0
  38. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/tradingview/tradingview_types.py +0 -0
  39. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/types_helper/__init__.py +0 -0
  40. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/types_helper/decorators.py +0 -0
  41. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/types_helper/model_config.py +0 -0
  42. {trd_utils-0.0.47 → trd_utils-0.0.48}/trd_utils/types_helper/ultra_list.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: trd_utils
3
- Version: 0.0.47
3
+ Version: 0.0.48
4
4
  Summary: Common Basic Utils for Python3. By ALiwoto.
5
5
  Keywords: utils,trd_utils,basic-utils,common-utils
6
6
  Author: ALiwoto
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "trd_utils"
3
- version = "0.0.47"
3
+ version = "0.0.48"
4
4
  description = "Common Basic Utils for Python3. By ALiwoto."
5
5
  authors = ["ALiwoto <aminnimaj@gmail.com>"]
6
6
  packages = [
@@ -0,0 +1,3 @@
1
+
2
+ __version__ = "0.0.48"
3
+
@@ -13,7 +13,7 @@ from trd_utils.date_utils.datetime_helpers import dt_from_ts, dt_to_ts
13
13
  from trd_utils.html_utils.html_formats import camel_to_snake
14
14
  from trd_utils.types_helper.model_config import ModelConfig
15
15
  from trd_utils.types_helper.ultra_list import convert_to_ultra_list
16
- from trd_utils.types_helper.utils import AbstractModel, get_my_field_types
16
+ from trd_utils.types_helper.utils import AbstractModel, get_my_field_types, is_type_optional
17
17
 
18
18
  # Whether to use ultra-list instead of normal python list or not.
19
19
  # This might be convenient in some cases, but it is not recommended
@@ -199,7 +199,7 @@ class BaseModel(AbstractModel):
199
199
 
200
200
  expected_type_args = get_type_args(expected_type)
201
201
  expected_type_name = getattr(expected_type, "__name__", None)
202
- is_optional_type = expected_type_name == "Optional"
202
+ is_optional_type = is_type_optional(expected_type)
203
203
  is_dict_type = expected_type_name == "dict"
204
204
  # maybe in the future we can have some other usages for is_optional_type
205
205
  # variable or something like that.
@@ -278,9 +278,16 @@ class BaseModel(AbstractModel):
278
278
  # raise ValueError(f"Missing required field: {field}")
279
279
 
280
280
  @classmethod
281
- def deserialize(cls, json_data: Union[str, dict]):
281
+ def deserialize(
282
+ cls,
283
+ json_data: Union[str, dict],
284
+ parse_float=Decimal,
285
+ ):
282
286
  if isinstance(json_data, str):
283
- data = json.loads(json_data)
287
+ data = json.loads(
288
+ json_data,
289
+ parse_float=parse_float,
290
+ )
284
291
  else:
285
292
  data = json_data
286
293
  return cls(**data)
@@ -5,6 +5,18 @@ from typing import (
5
5
  class AbstractModel:
6
6
  pass
7
7
 
8
+ def is_type_optional(target: type) -> bool:
9
+ if getattr(target, "__name__", None) == "Optional":
10
+ # e.g: my_field: Optional[str] = None
11
+ return True
12
+
13
+ target_args = getattr(target, "__args__", None)
14
+ if target_args and len(target_args) > 1 and target_args[1] is type(None):
15
+ # e.g: my_field: Decimal | None = None
16
+ return True
17
+
18
+ return False
19
+
8
20
  def get_real_attr(cls, attr_name):
9
21
  if cls is None:
10
22
  return None
@@ -1,3 +0,0 @@
1
-
2
- __version__ = "0.0.47"
3
-
File without changes
File without changes