From 2433fa01cdfd412cba2ad2f44c560593e92660dd Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Fri, 9 Jun 2023 22:22:12 +0200 Subject: [PATCH] Fix typing --- app/models.py | 11 +++++++---- app/uploads.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/models.py b/app/models.py index 0cf15c1..2c9c3de 100644 --- a/app/models.py +++ b/app/models.py @@ -1,4 +1,5 @@ import enum +from datetime import datetime from typing import Any from typing import Optional from typing import Union @@ -436,7 +437,7 @@ class OutboxObjectAttachment(Base): outbox_object_id = Column(Integer, ForeignKey("outbox.id"), nullable=False) upload_id = Column(Integer, ForeignKey("upload.id"), nullable=False) - upload = relationship(Upload, uselist=False) + upload: Mapped["Upload"] = relationship(Upload, uselist=False) class IndieAuthAuthorizationRequest(Base): @@ -459,7 +460,9 @@ class IndieAuthAccessToken(Base): __tablename__ = "indieauth_access_token" id = Column(Integer, primary_key=True, index=True) - created_at = Column(DateTime(timezone=True), nullable=False, default=now) + created_at: Mapped[datetime] = Column( + DateTime(timezone=True), nullable=False, default=now + ) # Will be null for personal access tokens indieauth_authorization_request_id = Column( @@ -470,9 +473,9 @@ class IndieAuthAccessToken(Base): uselist=False, ) - access_token = Column(String, nullable=False, unique=True, index=True) + access_token: Mapped[str] = Column(String, nullable=False, unique=True, index=True) refresh_token = Column(String, nullable=True, unique=True, index=True) - expires_in = Column(Integer, nullable=False) + expires_in: Mapped[int] = Column(Integer, nullable=False) scope = Column(String, nullable=False) is_revoked = Column(Boolean, nullable=False, default=False) was_refreshed = Column(Boolean, nullable=False, default=False, server_default="0") diff --git a/app/uploads.py b/app/uploads.py index 60f3151..d5c2079 100644 --- a/app/uploads.py +++ b/app/uploads.py @@ -60,7 +60,7 @@ async def save_upload(db_session: AsyncSession, f: UploadFile) -> models.Upload: destination_image.putdata(original_image.getdata()) destination_image.save( dest_filename, - format=_original_image.format, + format=_original_image.format, # type: ignore ) with open(dest_filename, "rb") as dest_f: