Skip to content

Commit c999f40

Browse files
authored
revert(metrics): typing regression on log_metrics callable (aws-powertools#744)
1 parent 989a4f6 commit c999f40

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

aws_lambda_powertools/metrics/metrics.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
import json
33
import logging
44
import warnings
5-
from typing import Any, Callable, Dict, Optional, Union, cast
5+
from typing import Any, Callable, Dict, Optional, Union
66

7-
from ..shared.types import AnyCallableT
87
from .base import MetricManager, MetricUnit
98
from .metric import single_metric
109

@@ -130,7 +129,7 @@ def log_metrics(
130129
capture_cold_start_metric: bool = False,
131130
raise_on_empty_metrics: bool = False,
132131
default_dimensions: Optional[Dict[str, str]] = None,
133-
) -> AnyCallableT:
132+
):
134133
"""Decorator to serialize and publish metrics at the end of a function execution.
135134
136135
Be aware that the log_metrics **does call* the decorated function (e.g. lambda_handler).
@@ -170,14 +169,11 @@ def handler(event, context):
170169
# Return a partial function with args filled
171170
if lambda_handler is None:
172171
logger.debug("Decorator called with parameters")
173-
return cast(
174-
AnyCallableT,
175-
functools.partial(
176-
self.log_metrics,
177-
capture_cold_start_metric=capture_cold_start_metric,
178-
raise_on_empty_metrics=raise_on_empty_metrics,
179-
default_dimensions=default_dimensions,
180-
),
172+
return functools.partial(
173+
self.log_metrics,
174+
capture_cold_start_metric=capture_cold_start_metric,
175+
raise_on_empty_metrics=raise_on_empty_metrics,
176+
default_dimensions=default_dimensions,
181177
)
182178

183179
@functools.wraps(lambda_handler)
@@ -198,7 +194,7 @@ def decorate(event, context):
198194

199195
return response
200196

201-
return cast(AnyCallableT, decorate)
197+
return decorate
202198

203199
def __add_cold_start_metric(self, context: Any) -> None:
204200
"""Add cold start metric and function_name dimension

0 commit comments

Comments
 (0)