python-aws-sam-translator/no-more-utcnow-in-metrics.patch
Steve Kowalik a828754d5c - Update to 1.84.0:
* chore(schema): update by @github-actions in #3490
  * chore(schema): update by @github-actions in #3492
  * chore(schema): update by @github-actions in #3494
  * chore(schema): update by @github-actions in #3497
  * chore: Less CloudFormation Schema Update PRs by @GavinZZ in #3498
  * chore(schema): update by @github-actions in #3499
  * chore(schema): update by @github-actions in #3503
  * Drop python3.7 support for SAM-T by @xazhao in #3403
  * chore(schema): update by @github-actions in #3404
  * fix: Raise exception when using dynamic reference in CodeUri Uri 
    format by @GavinZZ in #3405
  * chore: Update how we download CFN documentation by @GavinZZ in #3406
  * chore(schema): update by @github-actions in #3409
  * chore(schema): update by @github-actions in #3413
  * chore(schema): update by @github-actions in #3417
  * Merge main to develop by @xazhao in #3420
  * chore(schema): update by @github-actions in #3424
  * [chore]: keep cfn schema used by cfn-lint up-to-date by
    @ssenchenko in #3425
  * adding new appsync props by @ssenchenko in #3423
  * chore(schema): update by @github-actions in #3427
  * chore(schema): update by @github-actions in #3421
  * chore(schema): update by @github-actions in #3428
  * fix: Tags with value of False got evaluated to "" by
    @ConnorRobertson in #3429
  * chore(schema): update by @github-actions in #3430
  * chore(schema): update by @github-actions in #3441
  * fix: Msk Tests Failure due to Missing Permissions by @GavinZZ in #3443
  * chore: mq tests using a valid version by @ConnorRobertson in #3442

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:aws/python-aws-sam-translator?expand=0&rev=50
2024-02-08 02:09:00 +00:00

39 lines
1.4 KiB
Diff

From aca3d4dca40b8d6b48c0a0f3b4bab5b0406f9865 Mon Sep 17 00:00:00 2001
From: Steve Kowalik <steven@wedontsleep.org>
Date: Thu, 8 Feb 2024 12:58:06 +1100
Subject: [PATCH] Use datetime.now(utc) in MetricDatum
datetime.utcnow() is deprecated as of Python 3.12, and its use will
raise a DeprecationWarning. Since warnings are treated as errors, this
results in test failures under Python 3.12. Switch to using
datetime.now() with a timezone.utc parameter.
---
samtranslator/metrics/metrics.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/samtranslator/metrics/metrics.py b/samtranslator/metrics/metrics.py
index d026e9c13..72da530b7 100644
--- a/samtranslator/metrics/metrics.py
+++ b/samtranslator/metrics/metrics.py
@@ -1,9 +1,10 @@
"""
Helper classes to publish metrics
"""
+
import logging
from abc import ABC, abstractmethod
-from datetime import datetime
+from datetime import datetime, timezone
from typing import Any, Dict, List, Optional, TypedDict, Union
from samtranslator.internal.deprecation_control import deprecated
@@ -114,7 +115,7 @@ def __init__(
self.value = value
self.unit = unit
self.dimensions = dimensions if dimensions else []
- self.timestamp = timestamp if timestamp else datetime.utcnow()
+ self.timestamp = timestamp if timestamp else datetime.now(timezone.utc)
def get_metric_data(self) -> Dict[str, Any]:
return {