mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-10-03 17:15:19 -07:00
Replace deprecated datetime.utcnow() with datetime.now(UTC) throughout
Python 3.12 deprecates datetime.utcnow() with a DeprecationWarning and
it will be removed in a future release. Replace all call-site usages in
services, routes, and utils with datetime.now(UTC), and replace the
SQLAlchemy ORM column defaults (which used the bare function reference
datetime.utcnow) with lambda: datetime.now(UTC) so that the returned
objects are timezone-aware and consistent with Python best practice.
Affected: database/models.py, services/{stories,history,profiles,
channels,export_import}.py, routes/{profiles,tasks}.py, utils/tasks.py
This commit is contained in:
@@ -3,7 +3,7 @@ Task tracking for active downloads and generations.
|
||||
"""
|
||||
|
||||
from typing import Optional, Dict, List
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class DownloadTask:
|
||||
"""Represents an active download task."""
|
||||
model_name: str
|
||||
status: str = "downloading" # downloading, extracting, complete, error
|
||||
started_at: datetime = field(default_factory=datetime.utcnow)
|
||||
started_at: datetime = field(default_factory=lambda: datetime.now(UTC))
|
||||
error: Optional[str] = None
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class GenerationTask:
|
||||
task_id: str
|
||||
profile_id: str
|
||||
text_preview: str # First 50 chars of text
|
||||
started_at: datetime = field(default_factory=datetime.utcnow)
|
||||
started_at: datetime = field(default_factory=lambda: datetime.now(UTC))
|
||||
|
||||
|
||||
class TaskManager:
|
||||
|
||||
Reference in New Issue
Block a user