From 9eaea1d9c57d12e9b930100ffd2aa6f0b4ed1e9d Mon Sep 17 00:00:00 2001 From: Martin Kulhavy Date: Sun, 26 Oct 2025 20:19:03 +0200 Subject: [PATCH] fix(typing): Fix type of Metrics.set_timestamp argument The docstring is correct but the type hint is not. The underlying AmazonCloudWatchEMFProvider.set_timestamp supports both int and datetime.datetime. --- aws_lambda_powertools/metrics/metrics.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aws_lambda_powertools/metrics/metrics.py b/aws_lambda_powertools/metrics/metrics.py index 873f09c6377..c8c16e8bd51 100644 --- a/aws_lambda_powertools/metrics/metrics.py +++ b/aws_lambda_powertools/metrics/metrics.py @@ -6,6 +6,7 @@ from aws_lambda_powertools.metrics.provider.cloudwatch_emf.cloudwatch import AmazonCloudWatchEMFProvider if TYPE_CHECKING: + import datetime from collections.abc import Callable from aws_lambda_powertools.metrics.base import MetricResolution, MetricUnit @@ -133,7 +134,7 @@ def serialize_metric_set( def add_metadata(self, key: str, value: Any) -> None: self.provider.add_metadata(key=key, value=value) - def set_timestamp(self, timestamp: int): + def set_timestamp(self, timestamp: int | datetime.datetime): """ Set the timestamp for the metric.