From 964eabed052fdbe4cffdb6ddcbfc1ae455d652f9 Mon Sep 17 00:00:00 2001 From: Misha Tomilov Date: Fri, 17 Jan 2025 19:01:43 +0100 Subject: [PATCH] Add new Mention model --- h/models/mention.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/h/models/mention.py b/h/models/mention.py index d43d78aba42..04afb6bfab6 100644 --- a/h/models/mention.py +++ b/h/models/mention.py @@ -1,4 +1,5 @@ import sqlalchemy as sa +from sqlalchemy.orm import Mapped, mapped_column from h.db import Base from h.db.mixins import Timestamps @@ -8,9 +9,9 @@ class Mention(Base, Timestamps): # pragma: nocover __tablename__ = "mention" - id = sa.Column(sa.Integer, autoincrement=True, primary_key=True) + id: Mapped[int] = mapped_column(sa.Integer, autoincrement=True, primary_key=True) - annotation_id = sa.Column( + annotation_id: Mapped[int] = mapped_column( sa.Integer, sa.ForeignKey("annotation_slim.id", ondelete="CASCADE"), nullable=False, @@ -18,7 +19,7 @@ class Mention(Base, Timestamps): # pragma: nocover """FK to annotation_slim.id""" annotation = sa.orm.relationship("AnnotationSlim") - user_id = sa.Column( + user_id: Mapped[int] = mapped_column( sa.Integer, sa.ForeignKey("user.id", ondelete="CASCADE"), nullable=False, @@ -27,5 +28,5 @@ class Mention(Base, Timestamps): # pragma: nocover """FK to user.id""" user = sa.orm.relationship("User") - def __repr__(self): + def __repr__(self) -> str: return helpers.repr_(self, ["id", "annotation_id", "user_id"])