refactor: Update timezone.utc to UTC

This commit is contained in:
Matthias
2025-07-04 08:58:54 +02:00
parent a7ee45a0ba
commit 5b8b80cf59
7 changed files with 38 additions and 38 deletions

View File

@@ -1,6 +1,6 @@
import logging
import secrets
from datetime import datetime, timedelta, timezone
from datetime import UTC, datetime, timedelta
from typing import Any
import jwt
@@ -89,15 +89,15 @@ async def validate_ws_token(
def create_token(data: dict, secret_key: str, token_type: str = "access") -> str: # noqa: S107
to_encode = data.copy()
if token_type == "access": # noqa: S105
expire = datetime.now(timezone.utc) + timedelta(minutes=15)
expire = datetime.now(UTC) + timedelta(minutes=15)
elif token_type == "refresh": # noqa: S105
expire = datetime.now(timezone.utc) + timedelta(days=30)
expire = datetime.now(UTC) + timedelta(days=30)
else:
raise ValueError()
to_encode.update(
{
"exp": expire,
"iat": datetime.now(timezone.utc),
"iat": datetime.now(UTC),
"type": token_type,
}
)

View File

@@ -1,7 +1,7 @@
from typing import Any, Literal
from typing import Any, Literal, NotRequired
from uuid import uuid4
from typing_extensions import NotRequired, TypedDict
from typing_extensions import TypedDict
from freqtrade.exchange.exchange import Exchange

View File

@@ -266,7 +266,7 @@ class ExternalMessageConsumer:
except Exception as e:
logger.exception(f"Error handling producer message: {e}")
except (asyncio.TimeoutError, websockets.exceptions.ConnectionClosed):
except (TimeoutError, websockets.exceptions.ConnectionClosed):
# We haven't received data yet. Check the connection and continue.
try:
# ping