trd-utils 0.0.8__tar.gz → 0.0.10__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 (24) hide show
  1. {trd_utils-0.0.8 → trd_utils-0.0.10}/PKG-INFO +1 -1
  2. {trd_utils-0.0.8 → trd_utils-0.0.10}/pyproject.toml +1 -1
  3. trd_utils-0.0.10/trd_utils/__init__.py +3 -0
  4. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/types_helper/base_model.py +26 -10
  5. trd_utils-0.0.8/trd_utils/__init__.py +0 -3
  6. {trd_utils-0.0.8 → trd_utils-0.0.10}/LICENSE +0 -0
  7. {trd_utils-0.0.8 → trd_utils-0.0.10}/README.md +0 -0
  8. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/cipher/__init__.py +0 -0
  9. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/common_utils/float_utils.py +0 -0
  10. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/exchanges/__init__.py +0 -0
  11. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/exchanges/blofin/__init__.py +0 -0
  12. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/exchanges/blofin/blofin_client.py +0 -0
  13. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/exchanges/blofin/blofin_types.py +0 -0
  14. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/exchanges/bx_ultra/__init__.py +0 -0
  15. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/exchanges/bx_ultra/bx_types.py +0 -0
  16. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/exchanges/bx_ultra/bx_ultra_client.py +0 -0
  17. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/exchanges/bx_ultra/bx_utils.py +0 -0
  18. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/exchanges/exchange_base.py +0 -0
  19. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/html_utils/__init__.py +0 -0
  20. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/html_utils/html_formats.py +0 -0
  21. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/tradingview/__init__.py +0 -0
  22. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/tradingview/tradingview_client.py +0 -0
  23. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/tradingview/tradingview_types.py +0 -0
  24. {trd_utils-0.0.8 → trd_utils-0.0.10}/trd_utils/types_helper/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: trd_utils
3
- Version: 0.0.8
3
+ Version: 0.0.10
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.8"
3
+ version = "0.0.10"
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.10"
3
+
@@ -48,7 +48,7 @@ def is_any_type(target_type: type) -> bool:
48
48
 
49
49
 
50
50
  # TODO: add support for max_depth for this...
51
- def value_to_normal_obj(value):
51
+ def value_to_normal_obj(value, omit_none: bool = False,):
52
52
  """
53
53
  Converts a custom value, to a corresponding "normal object" which can be used
54
54
  in dict.
@@ -71,7 +71,11 @@ def value_to_normal_obj(value):
71
71
  if isinstance(value, dict):
72
72
  result = {}
73
73
  for inner_key, inner_value in value.items():
74
- result[inner_key] = value_to_normal_obj(inner_value)
74
+ normalized_value = value_to_normal_obj(inner_value)
75
+ if normalized_value is None and omit_none:
76
+ continue
77
+
78
+ result[inner_key] = normalized_value
75
79
 
76
80
  return result
77
81
 
@@ -92,11 +96,13 @@ def generic_obj_to_value(
92
96
  if isinstance(value, list):
93
97
  result = []
94
98
  for current in value:
95
- result.append(generic_obj_to_value(
96
- expected_type=expected_type_args[0],
97
- expected_type_args=expected_type_args[1:],
98
- value=current,
99
- ))
99
+ result.append(
100
+ generic_obj_to_value(
101
+ expected_type=expected_type_args[0],
102
+ expected_type_args=expected_type_args[1:],
103
+ value=current,
104
+ )
105
+ )
100
106
  return result
101
107
 
102
108
  expected_type_name = getattr(expected_type, "__name__", None)
@@ -266,16 +272,26 @@ class BaseModel:
266
272
  sort_keys=sort_keys,
267
273
  )
268
274
 
269
- def to_dict(self) -> dict:
275
+ def to_dict(
276
+ self,
277
+ omit_none: bool = False,
278
+ ) -> dict:
270
279
  annotations = get_my_field_types(self)
271
280
  result_dict = {}
272
281
  for key, _ in annotations.items():
273
282
  if not isinstance(key, str):
274
283
  continue
275
284
 
276
- if key.startswith("__"):
285
+ if key.startswith("__") or key.startswith(f"_{self.__class__.__name__}__"):
277
286
  # ignore private attributes
278
287
  continue
279
288
 
280
- result_dict[key] = value_to_normal_obj(getattr(self, key))
289
+ normalized_value = value_to_normal_obj(
290
+ value=getattr(self, key),
291
+ omit_none=omit_none,
292
+ )
293
+ if normalized_value is None and omit_none:
294
+ continue
295
+
296
+ result_dict[key] = normalized_value
281
297
  return result_dict
@@ -1,3 +0,0 @@
1
-
2
- __version__ = "0.0.8"
3
-
File without changes
File without changes