feat: Upgrade to Python 3.12 (#4675)

Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
This commit is contained in:
Michael Genson
2024-12-04 22:31:26 -06:00
committed by GitHub
parent 0e6a40e210
commit 87504fbb05
43 changed files with 128 additions and 163 deletions

View File

@@ -3,7 +3,7 @@ from functools import lru_cache
import requests
_LAST_RESET = None
_LAST_RESET: datetime.datetime | None = None
@lru_cache(maxsize=1)
@@ -32,7 +32,7 @@ def get_latest_version() -> str:
global _LAST_RESET
now = datetime.datetime.now(datetime.timezone.utc)
now = datetime.datetime.now(datetime.UTC)
if not _LAST_RESET or now - _LAST_RESET > datetime.timedelta(days=MAX_DAYS_OLD):
_LAST_RESET = now

View File

@@ -1,5 +1,5 @@
import abc
from datetime import datetime, timedelta, timezone
from datetime import UTC, datetime, timedelta
from typing import Generic, TypeVar
import jwt
@@ -45,7 +45,7 @@ class AuthProvider(Generic[T], metaclass=abc.ABCMeta):
to_encode = data.copy()
expires_delta = expires_delta or timedelta(hours=settings.TOKEN_TIME)
expire = datetime.now(timezone.utc) + expires_delta
expire = datetime.now(UTC) + expires_delta
to_encode["exp"] = expire
to_encode["iss"] = ISS

View File

@@ -1,5 +1,5 @@
import secrets
from datetime import datetime, timedelta, timezone
from datetime import UTC, datetime, timedelta
from pathlib import Path
import jwt
@@ -34,7 +34,7 @@ def create_access_token(data: dict, expires_delta: timedelta | None = None) -> s
to_encode = data.copy()
expires_delta = expires_delta or timedelta(hours=settings.TOKEN_TIME)
expire = datetime.now(timezone.utc) + expires_delta
expire = datetime.now(UTC) + expires_delta
to_encode["exp"] = expire
return jwt.encode(to_encode, settings.SECRET, algorithm=ALGORITHM)

View File

@@ -1,7 +1,7 @@
import logging
import os
import secrets
from datetime import datetime, timezone
from datetime import UTC, datetime
from pathlib import Path
from typing import Annotated, Any, NamedTuple
@@ -160,7 +160,7 @@ class AppSettings(AppLoggingSettings):
local_tz = tzlocal()
now = datetime.now(local_tz)
local_time = now.replace(hour=local_hour, minute=local_minute)
utc_time = local_time.astimezone(timezone.utc)
utc_time = local_time.astimezone(UTC)
self.logger.debug(f"Local time: {local_hour}:{local_minute} | UTC time: {utc_time.hour}:{utc_time.minute}")
return ScheduleTime(utc_time.hour, utc_time.minute)