From e17d7c45d062b06294163c832787fa8b95d80974 Mon Sep 17 00:00:00 2001 From: s-heppner Date: Thu, 14 Nov 2024 17:39:11 +0100 Subject: [PATCH] adapter.http: Fix reference to constant from the future Currently, we're using `datetime.UTC`, a constant defined in the built-in `datetime` module. However, this constant was only introduced in Python version 3.11, as you can see in the documentation: - Does not exist in [datetime Python 3.10] - Exists in [datetime python 3.11] We did not catch this, as we most likely programmed the module with Python >= 3.11 and our CI also ran `mypy` with Python 3.12. [datetime Python 3.10]: https://docs.python.org/3.10/library/datetime.html#constants [datetime python 3.11]: https://docs.python.org/3.11/library/datetime.html#datetime.UTC Fixes #330 --- sdk/basyx/aas/adapter/http.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/basyx/aas/adapter/http.py b/sdk/basyx/aas/adapter/http.py index df3a8e9c..18f2baf8 100644 --- a/sdk/basyx/aas/adapter/http.py +++ b/sdk/basyx/aas/adapter/http.py @@ -80,7 +80,8 @@ def __init__(self, code: str, text: str, message_type: MessageType = MessageType self.code: str = code self.text: str = text self.message_type: MessageType = message_type - self.timestamp: datetime.datetime = timestamp if timestamp is not None else datetime.datetime.now(datetime.UTC) + self.timestamp: datetime.datetime = timestamp if timestamp is not None \ + else datetime.datetime.now(datetime.timezone.utc) class Result: