u-toolkit 0.1.14__py3-none-any.whl → 0.1.15__py3-none-any.whl

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.
u_toolkit/decorators.py CHANGED
@@ -53,19 +53,25 @@ def define_method_handler(
53
53
 
54
54
  _P = ParamSpec("_P")
55
55
 
56
+ _T2 = TypeVar("_T2")
57
+
56
58
 
57
59
  def create_decorator(
58
- handle: Callable[_P] | None = None,
60
+ handle: Callable[_P, _T2] | None = None,
61
+ use_handle_return: bool | None = None,
59
62
  ):
60
63
  def decorator(fn: Callable[_P, _T]):
61
64
  if inspect.iscoroutinefunction(fn):
62
65
 
63
66
  @wraps(fn)
64
67
  async def async_wrapper(*args, **kwargs):
68
+ handle_result = None
65
69
  if inspect.iscoroutinefunction(handle):
66
- await handle(*args, **kwargs)
70
+ handle_result = await handle(*args, **kwargs)
67
71
  elif handle:
68
- handle(*args, **kwargs)
72
+ handle_result = handle(*args, **kwargs)
73
+ if use_handle_return:
74
+ return handle_result
69
75
  return await fn(*args, **kwargs)
70
76
 
71
77
  return async_wrapper
@@ -73,7 +79,10 @@ def create_decorator(
73
79
  @wraps(fn)
74
80
  def wrapper(*args: _P.args, **kwargs: _P.kwargs):
75
81
  if handle:
76
- handle(*args, **kwargs)
82
+ handle_result = handle(*args, **kwargs)
83
+ if use_handle_return:
84
+ return handle_result
85
+
77
86
  return fn(*args, **kwargs)
78
87
 
79
88
  return wrapper
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: u-toolkit
3
- Version: 0.1.14
3
+ Version: 0.1.15
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: pydantic>=2.11.3
@@ -1,7 +1,7 @@
1
1
  u_toolkit/__init__.py,sha256=7f_bFg1UERA4gyh3HjCAjOZo2cBUgElpwgX5x-Xk2WA,238
2
2
  u_toolkit/alias_generators.py,sha256=KmPL1ViGJjptONffZUAX4ENvkldrwDylm_Ly5RYE8b4,963
3
3
  u_toolkit/datetime.py,sha256=GOG0xa6yKeqvFXJkImK5Pt7wsPXnHMlNKju8deniGJ4,644
4
- u_toolkit/decorators.py,sha256=3AQ_NMT7YfKDNFBX07chghktwhTBlIcTjAzjgVMmfNI,2082
4
+ u_toolkit/decorators.py,sha256=rBZfXtWVfja6YMDqF9izjAiabRVyp4pAWOlwnN0HkUw,2396
5
5
  u_toolkit/enum.py,sha256=2yWmK8V1q0P5S3ltBED-TF2H09BmRbsBuqu3Th3G1NE,862
6
6
  u_toolkit/function.py,sha256=GAE6TIm5jpemUiNUPjzk7pIHrxwSSX7sHl1V5E735dE,252
7
7
  u_toolkit/helpers.py,sha256=K3FCz93K1nT4o7gWKVpMKy3k3BnirTPCSb8F8EFUrWk,112
@@ -30,7 +30,7 @@ u_toolkit/sqlalchemy/type_vars.py,sha256=m2VeV41CBIK_1QX3w2kgz-n556sILAGZ-Kaz3TD
30
30
  u_toolkit/sqlalchemy/orm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  u_toolkit/sqlalchemy/orm/fields.py,sha256=3zoYil23I6YLtc_59aHDt9w5l1NBTkePT9AfXI3DMiY,593
32
32
  u_toolkit/sqlalchemy/orm/models.py,sha256=V8vf4ps3phAmwxyaFYK7pw8Igz7h097o4QBjKB0gwC8,705
33
- u_toolkit-0.1.14.dist-info/METADATA,sha256=-mn37kFXx78jKuagV5ZFLhtjjvIV2wx3dfB3_EhWpjU,366
34
- u_toolkit-0.1.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
- u_toolkit-0.1.14.dist-info/entry_points.txt,sha256=hTfAYCd5vvRiqgnJk2eBsoRIiIVB9pK8WZm3Q3jjKFU,45
36
- u_toolkit-0.1.14.dist-info/RECORD,,
33
+ u_toolkit-0.1.15.dist-info/METADATA,sha256=9YW-ZY96UyD1LCdAKjIGAVWbvOM8mqaCvcP-152uIVU,366
34
+ u_toolkit-0.1.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
+ u_toolkit-0.1.15.dist-info/entry_points.txt,sha256=hTfAYCd5vvRiqgnJk2eBsoRIiIVB9pK8WZm3Q3jjKFU,45
36
+ u_toolkit-0.1.15.dist-info/RECORD,,