diff options
| author | Dennis Fink | 2026-11-13 17:30:03 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-13 17:30:03 +0100 |
| commit | 177186a0952d51fc41f51e09a1ac8e60fdb26bd8 (patch) | |
| tree | 48e855ed37bf483d499d4cc51175e9678c61c492 /webmentions_ssg/models.py | |
| parent | f801d8acef788a7ce676adc099ebcb5618db94b2 (diff) | |
| download | webmentions-ssg-177186a0952d51fc41f51e09a1ac8e60fdb26bd8.tar.gz webmentions-ssg-177186a0952d51fc41f51e09a1ac8e60fdb26bd8.zip | |
refactor(core): avoid uuid module shadowing in models
Import `UUID` and `uuid7` directly so model column attributes named
`uuid` no longer shadow the module used for type annotations and default
generators.
Diffstat (limited to 'webmentions_ssg/models.py')
| -rw-r--r-- | webmentions_ssg/models.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/webmentions_ssg/models.py b/webmentions_ssg/models.py index 48d8532..0932962 100644 --- a/webmentions_ssg/models.py +++ b/webmentions_ssg/models.py @@ -7,11 +7,11 @@ from __future__ import annotations import json -import uuid from datetime import UTC, datetime from enum import StrEnum from hashlib import sha256 from typing import Never +from uuid import UUID, uuid7 from flask_login import UserMixin from sqlalchemy import ( @@ -106,7 +106,7 @@ class ReceivedWebmention(Base): __tablename__ = "received_webmentions" - uuid: Mapped[uuid.UUID] = mapped_column(Uuid(as_uuid=True), primary_key=True) + uuid: Mapped[UUID] = mapped_column(Uuid(as_uuid=True), primary_key=True) source: Mapped[str] = mapped_column(Text(), nullable=False) target: Mapped[str] = mapped_column(Text(), nullable=False) @@ -195,8 +195,8 @@ class Source(Base): __tablename__ = "sources" - uuid: Mapped[uuid.UUID] = mapped_column( - Uuid(as_uuid=True), primary_key=True, default=uuid.uuid7 + uuid: Mapped[UUID] = mapped_column( + Uuid(as_uuid=True), primary_key=True, default=uuid7 ) path: Mapped[str] = mapped_column(Text(), nullable=False, unique=True) @@ -240,11 +240,11 @@ class SentWebmention(Base): __tablename__ = "sent_webmentions" - uuid: Mapped[uuid.UUID] = mapped_column( - Uuid(as_uuid=True), primary_key=True, default=uuid.uuid7 + uuid: Mapped[UUID] = mapped_column( + Uuid(as_uuid=True), primary_key=True, default=uuid7 ) - source_id: Mapped[uuid.UUID] = mapped_column( + source_id: Mapped[UUID] = mapped_column( Uuid(as_uuid=True), ForeignKey("sources.uuid", ondelete="CASCADE"), nullable=False, @@ -357,7 +357,7 @@ class SentWebmention(Base): return uuid7_to_datetime(self.uuid) -def uuid7_to_datetime(identifier: uuid.UUID) -> datetime: +def uuid7_to_datetime(identifier: UUID) -> datetime: """Convert a UUID version 7 timestamp to a datetime. :param identifier: UUID whose embedded timestamp should be converted. |
