Skip to content

Commit 1a81056

Browse files
committed
Fix more datetime.utcnow deprecation warnings
1 parent 4d2c4f3 commit 1a81056

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/laniakea/db/debcheck.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import json
88
import uuid
99
from uuid import uuid4
10-
from datetime import datetime
10+
from datetime import UTC, datetime
1111

1212
from sqlalchemy import Enum, Text, Index, String, Integer, DateTime, ForeignKey
1313
from marshmallow import EXCLUDE, Schema, fields
@@ -63,7 +63,7 @@ class DebcheckIssue(Base):
6363

6464
uuid: Mapped[UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid4)
6565

66-
time: Mapped[datetime] = mapped_column(DateTime(), default=datetime.utcnow) # Time when this excuse was created
66+
time: Mapped[datetime] = mapped_column(DateTime(), default=lambda: datetime.now(UTC)) # Time when this excuse was created
6767

6868
package_type: Mapped[PackageType] = mapped_column(Enum(PackageType))
6969

src/laniakea/db/jobs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import enum
88
from enum import IntEnum
99
from uuid import uuid4
10-
from datetime import datetime
10+
from datetime import UTC, datetime
1111

1212
from sqlalchemy import Enum, Text, Index, String, Integer, DateTime, ForeignKey
1313
from sqlalchemy.orm import Mapped, relationship, mapped_column
@@ -96,7 +96,7 @@ class Job(Base):
9696
architecture: Mapped[str] = mapped_column(String(80), default='any')
9797

9898
time_created: Mapped[datetime] = mapped_column(
99-
DateTime(), default=datetime.utcnow
99+
DateTime(), default=lambda: datetime.now(UTC)
100100
) # Time when this job was created.
101101
time_assigned: Mapped[datetime] = mapped_column(
102102
DateTime(), nullable=True

src/laniakea/db/spears.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from uuid import uuid4
88
from typing import Any
9-
from datetime import datetime
9+
from datetime import UTC, datetime
1010

1111
from sqlalchemy import (
1212
Text,
@@ -41,7 +41,7 @@ class SpearsHint(Base):
4141
'SpearsMigrationTask'
4242
) # Migration task this hint belongs to
4343

44-
time: Mapped[datetime] = mapped_column(DateTime(), default=datetime.utcnow) # Time when this hint was created
44+
time: Mapped[datetime] = mapped_column(DateTime(), default=lambda: datetime.now(UTC)) # Time when this hint was created
4545
hint: Mapped[str] = mapped_column(Text()) # A Britney hint
4646
reason: Mapped[str] = mapped_column(Text()) # Reason why the package is blacklisted
4747

src/laniakea/db/workers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import enum
88
from enum import IntEnum
99
from uuid import uuid4
10-
from datetime import datetime
10+
from datetime import UTC, datetime
1111

1212
from sqlalchemy import Enum, Text, Boolean, DateTime
1313
from sqlalchemy.orm import Mapped, mapped_column
@@ -41,7 +41,7 @@ class SparkWorker(Base):
4141
owner: Mapped[str] = mapped_column(Text(), nullable=True) # Owner of this worker
4242

4343
time_created: Mapped[datetime] = mapped_column(
44-
DateTime(), default=datetime.utcnow
44+
DateTime(), default=lambda: datetime.now(UTC)
4545
) # Time when this worker was registered/created
4646

4747
accepts: Mapped[list[str]] = mapped_column(ARRAY(Text()), default=[]) # Modules this worker will accept jobs for
@@ -55,7 +55,7 @@ class SparkWorker(Base):
5555
enabled: Mapped[bool] = mapped_column(Boolean(), default=False) # Whether this worker should receive jobs or not
5656

5757
last_ping: Mapped[datetime] = mapped_column(
58-
DateTime(), default=datetime.utcnow
58+
DateTime(), default=lambda: datetime.now(UTC)
5959
) # Time when we last got a message from the worker
6060

6161
data: Mapped[dict] = mapped_column(JSON, default={}) # Custom worker properties

0 commit comments

Comments
 (0)