Skip to content

Commit

Permalink
fixes types
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobessa committed Nov 28, 2024
1 parent 815a6a0 commit c76e276
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added vintasend_sqlalchemy/py.typed
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Generic, TypeVar
import uuid
from collections.abc import Iterable

Expand All @@ -21,10 +21,12 @@
from vintasend.services.notification_backends.base import BaseNotificationBackend

if TYPE_CHECKING:
from vintasend_sqlalchemy.model_factory import NotificationMixin as NotificationModel
from vintasend_sqlalchemy.model_factory import NotificationMixin


class SQLAlchemyNotificationBackend(BaseNotificationBackend):
NotificationModel = TypeVar("NotificationModel", bound="NotificationMixin")

class SQLAlchemyNotificationBackend(Generic[NotificationModel], BaseNotificationBackend):
session: sessionmaker[Session]
notification_model_cls: "type[NotificationModel]"

Expand Down Expand Up @@ -254,13 +256,11 @@ def _update_notification_status(
return self.serialize_notification(notification_instance)

def filter_all_in_app_unread_notifications(
self, user_id: int | str | uuid.UUID, page: int, page_size: int
self, user_id: int | str | uuid.UUID
) -> Iterable[Notification]:
with self.session_manager.begin() as session:
query = (
self._get_all_in_app_unread_notifications_query(session, user_id)
.offset((page - 1) * page_size)
.limit(page_size)
)
notifications = query.all()
return (self.serialize_notification(notification) for notification in notifications)
Expand Down Expand Up @@ -307,7 +307,7 @@ def get_future_notifications_from_user(self, user_id: int | str | uuid.UUID, pag
session.expunge_all()
return (self.serialize_notification(notification) for notification in notifications)

def get_user_email_from_notification(self, notification_id: int | str | uuid.UUID) -> str | None:
def get_user_email_from_notification(self, notification_id: int | str | uuid.UUID) -> str:
with self.session_manager.begin() as session:
notification = (
session.query(self.notification_model_cls)
Expand Down

0 comments on commit c76e276

Please sign in to comment.