trd-utils 0.0.9__tar.gz → 0.0.11__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.9 → trd_utils-0.0.11}/PKG-INFO +1 -1
  2. {trd_utils-0.0.9 → trd_utils-0.0.11}/pyproject.toml +1 -1
  3. trd_utils-0.0.11/trd_utils/__init__.py +3 -0
  4. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/types_helper/base_model.py +32 -13
  5. trd_utils-0.0.9/trd_utils/__init__.py +0 -3
  6. {trd_utils-0.0.9 → trd_utils-0.0.11}/LICENSE +0 -0
  7. {trd_utils-0.0.9 → trd_utils-0.0.11}/README.md +0 -0
  8. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/cipher/__init__.py +0 -0
  9. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/common_utils/float_utils.py +0 -0
  10. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/exchanges/__init__.py +0 -0
  11. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/exchanges/blofin/__init__.py +0 -0
  12. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/exchanges/blofin/blofin_client.py +0 -0
  13. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/exchanges/blofin/blofin_types.py +0 -0
  14. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/exchanges/bx_ultra/__init__.py +0 -0
  15. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/exchanges/bx_ultra/bx_types.py +0 -0
  16. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/exchanges/bx_ultra/bx_ultra_client.py +0 -0
  17. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/exchanges/bx_ultra/bx_utils.py +0 -0
  18. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/exchanges/exchange_base.py +0 -0
  19. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/html_utils/__init__.py +0 -0
  20. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/html_utils/html_formats.py +0 -0
  21. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/tradingview/__init__.py +0 -0
  22. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/tradingview/tradingview_client.py +0 -0
  23. {trd_utils-0.0.9 → trd_utils-0.0.11}/trd_utils/tradingview/tradingview_types.py +0 -0
  24. {trd_utils-0.0.9 → trd_utils-0.0.11}/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.9
3
+ Version: 0.0.11
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.9"
3
+ version = "0.0.11"
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.11"
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)
@@ -255,18 +261,24 @@ class BaseModel:
255
261
 
256
262
  def serialize(
257
263
  self,
258
- separators=(",", ":"),
259
- ensure_ascii=True,
260
- sort_keys=True,
264
+ separators = (",", ":"),
265
+ ensure_ascii: bool = True,
266
+ sort_keys: bool = True,
267
+ omit_none: bool = False,
261
268
  ) -> bytes:
262
269
  return json.dumps(
263
- obj=self.to_dict(),
270
+ obj=self.to_dict(
271
+ omit_none=omit_none,
272
+ ),
264
273
  ensure_ascii=ensure_ascii,
265
274
  separators=separators,
266
275
  sort_keys=sort_keys,
267
276
  )
268
277
 
269
- def to_dict(self) -> dict:
278
+ def to_dict(
279
+ self,
280
+ omit_none: bool = False,
281
+ ) -> dict:
270
282
  annotations = get_my_field_types(self)
271
283
  result_dict = {}
272
284
  for key, _ in annotations.items():
@@ -277,5 +289,12 @@ class BaseModel:
277
289
  # ignore private attributes
278
290
  continue
279
291
 
280
- result_dict[key] = value_to_normal_obj(getattr(self, key))
292
+ normalized_value = value_to_normal_obj(
293
+ value=getattr(self, key),
294
+ omit_none=omit_none,
295
+ )
296
+ if normalized_value is None and omit_none:
297
+ continue
298
+
299
+ result_dict[key] = normalized_value
281
300
  return result_dict
@@ -1,3 +0,0 @@
1
-
2
- __version__ = "0.0.9"
3
-
File without changes
File without changes