turbo-lambda 0.7.1__tar.gz → 0.8.0__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.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: turbo-lambda
3
- Version: 0.7.1
3
+ Version: 0.8.0
4
4
  Summary: Turbo Lambda Description
5
5
  Author: Sam Mosleh
6
6
  Author-email: Sam Mosleh <sam.mosleh.d@gmail.com>
7
7
  Requires-Dist: opentelemetry-api>=1.27.0
8
8
  Requires-Dist: pydantic-settings>=2.11.0
9
- Requires-Python: >=3.12
9
+ Requires-Python: >=3.14
10
10
  Description-Content-Type: text/markdown
11
11
 
12
12
  # turbo-lambda
@@ -1,10 +1,10 @@
1
1
  [project]
2
2
  name = "turbo-lambda"
3
- version = "0.7.1"
3
+ version = "0.8.0"
4
4
  description = "Turbo Lambda Description"
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Sam Mosleh", email = "sam.mosleh.d@gmail.com" }]
7
- requires-python = ">=3.12"
7
+ requires-python = ">=3.14"
8
8
  dependencies = [
9
9
  "opentelemetry-api>=1.27.0",
10
10
  "pydantic-settings>=2.11.0",
@@ -1,3 +1,4 @@
1
+ import annotationlib
1
2
  import contextlib
2
3
  import contextvars
3
4
  import datetime
@@ -57,6 +58,10 @@ def _setup_logger() -> None: # pragma: no cover
57
58
  lambda_runtime_log_utils._json_encoder.default = _json_custom_default
58
59
 
59
60
 
61
+ def _default_result_extractor[T](res: T) -> dict[str, T]:
62
+ return {"result": res}
63
+
64
+
60
65
  @overload
61
66
  def log_after_call[**P, T](func: Callable[P, T]) -> Callable[P, T]: ...
62
67
 
@@ -68,7 +73,7 @@ def log_after_call[**P, T](
68
73
  log_message: str = "call",
69
74
  log_exceptions: bool = False,
70
75
  excluded_fields: Iterable[str] = ("self",),
71
- result_extractor: None = None,
76
+ result_extractor: bool = False,
72
77
  ) -> Callable[[Callable[P, T]], Callable[P, T]]: ...
73
78
 
74
79
 
@@ -89,10 +94,17 @@ def log_after_call[**P, T]( # noqa: PLR0913
89
94
  log_message: str = "call",
90
95
  log_exceptions: bool = False,
91
96
  excluded_fields: Iterable[str] = ("self",),
92
- result_extractor: Callable[[T], dict[str, Any]] | None = None,
97
+ result_extractor: Callable[[T], dict[str, Any]] | bool = False,
93
98
  ) -> Callable[P, T] | Callable[[Callable[P, T]], Callable[P, T]]:
94
99
  def decorator(func: Callable[P, T]) -> Callable[P, T]:
95
- sig = inspect.signature(func)
100
+ sig = inspect.signature(func, annotation_format=annotationlib.Format.STRING)
101
+ result_extractor_func = (
102
+ result_extractor
103
+ if callable(result_extractor)
104
+ else _default_result_extractor
105
+ if result_extractor
106
+ else None
107
+ )
96
108
 
97
109
  @wraps(func)
98
110
  def wrapper(*f_args: P.args, **f_kwargs: P.kwargs) -> T:
@@ -110,8 +122,8 @@ def log_after_call[**P, T]( # noqa: PLR0913
110
122
  st = time.monotonic()
111
123
  try:
112
124
  result = func(*f_args, **f_kwargs)
113
- if result_extractor:
114
- extra.update(result_extractor(result))
125
+ if result_extractor_func:
126
+ extra.update(result_extractor_func(result))
115
127
  return result
116
128
  except Exception as e:
117
129
  if log_exceptions:
File without changes