From 4248825af0c9a079b8c8326b3f96aba923b41e97 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 25 Aug 2022 12:06:59 +0200 Subject: [PATCH] Revert future imports for annotations, PEP563 is still defered Signed-off-by: Ferdinand Thiessen --- flaschengeist/models/image.py | 2 ++ flaschengeist/models/notification.py | 6 ++++-- flaschengeist/models/plugin.py | 2 ++ flaschengeist/models/session.py | 7 ++++--- flaschengeist/models/user.py | 6 ++++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/flaschengeist/models/image.py b/flaschengeist/models/image.py index 406fefe..101a19a 100644 --- a/flaschengeist/models/image.py +++ b/flaschengeist/models/image.py @@ -1,3 +1,5 @@ +from __future__ import annotations # TODO: Remove if python requirement is >= 3.12 (? PEP 563 is defered) + from sqlalchemy import event from pathlib import Path diff --git a/flaschengeist/models/notification.py b/flaschengeist/models/notification.py index 549a5b7..55e9640 100644 --- a/flaschengeist/models/notification.py +++ b/flaschengeist/models/notification.py @@ -1,3 +1,5 @@ +from __future__ import annotations # TODO: Remove if python requirement is >= 3.12 (? PEP 563 is defered) + from datetime import datetime from typing import Any @@ -14,8 +16,8 @@ class Notification(db.Model, ModelSerializeMixin): user_id_: int = db.Column("user", Serial, db.ForeignKey("user.id"), nullable=False) plugin_id_: int = db.Column("plugin", Serial, db.ForeignKey("plugin.id"), nullable=False) - user_: "User" = db.relationship("User") - plugin_: "Plugin" = db.relationship( + user_: User = db.relationship("User") + plugin_: Plugin = db.relationship( "Plugin", backref=db.backref("notifications_", cascade="all, delete, delete-orphan") ) diff --git a/flaschengeist/models/plugin.py b/flaschengeist/models/plugin.py index d2af46c..eb5cf35 100644 --- a/flaschengeist/models/plugin.py +++ b/flaschengeist/models/plugin.py @@ -1,3 +1,5 @@ +from __future__ import annotations # TODO: Remove if python requirement is >= 3.12 (? PEP 563 is defered) + from typing import Any from ..database import db diff --git a/flaschengeist/models/session.py b/flaschengeist/models/session.py index bf584fe..1dac1a3 100644 --- a/flaschengeist/models/session.py +++ b/flaschengeist/models/session.py @@ -1,11 +1,12 @@ +from __future__ import annotations # TODO: Remove if python requirement is >= 3.12 (? PEP 563 is defered) + from datetime import datetime, timedelta, timezone from secrets import compare_digest +from .. import logger from ..database import db from ..database.types import ModelSerializeMixin, UtcDateTime, Serial -from flaschengeist import logger - class Session(db.Model, ModelSerializeMixin): """Model for a Session @@ -26,7 +27,7 @@ class Session(db.Model, ModelSerializeMixin): _id = db.Column("id", Serial, primary_key=True) _user_id = db.Column("user_id", Serial, db.ForeignKey("user.id")) - user_: "User" = db.relationship("User", back_populates="sessions_") + user_: User = db.relationship("User", back_populates="sessions_") @property def userid(self): diff --git a/flaschengeist/models/user.py b/flaschengeist/models/user.py index 578758c..077b78c 100644 --- a/flaschengeist/models/user.py +++ b/flaschengeist/models/user.py @@ -1,3 +1,5 @@ +from __future__ import annotations # TODO: Remove if python requirement is >= 3.12 (? PEP 563 is defered) + from typing import Optional from datetime import date, datetime from sqlalchemy.orm.collections import attribute_mapped_collection @@ -62,10 +64,10 @@ class User(db.Model, ModelSerializeMixin): # Protected stuff for backend use only id_ = db.Column("id", Serial, primary_key=True) roles_: list[Role] = db.relationship("Role", secondary=association_table, cascade="save-update, merge") - sessions_: list["Session"] = db.relationship( + sessions_: list[Session] = db.relationship( "Session", back_populates="user_", cascade="all, delete, delete-orphan" ) - avatar_: Optional["Image"] = db.relationship("Image", cascade="all, delete, delete-orphan", single_parent=True) + avatar_: Optional[Image] = db.relationship("Image", cascade="all, delete, delete-orphan", single_parent=True) reset_requests_: list["_PasswordReset"] = db.relationship("_PasswordReset", cascade="all, delete, delete-orphan") # Private stuff for internal use