22import json
33import logging
44import 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
87from .base import MetricManager , MetricUnit
98from .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