Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

fix: remove NotImplementedError from Service base class. #222

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/starlite_saqlalchemy/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import TYPE_CHECKING, Any, ClassVar, Generic, TypeVar

from starlite_saqlalchemy.db import async_session_factory
from starlite_saqlalchemy.exceptions import NotFoundError
from starlite_saqlalchemy.repository.sqlalchemy import ModelT
from starlite_saqlalchemy.worker import queue

Expand Down Expand Up @@ -50,6 +51,8 @@ def __init_subclass__(cls, *_: Any, **__: Any) -> None:
cls.__id__ = f"{cls.__module__}.{cls.__name__}"
service_object_identity_map[cls.__id__] = cls

# pylint:disable=unused-argument

async def create(self, data: T) -> T:
"""Create an instance of `T`.

Expand All @@ -59,7 +62,7 @@ async def create(self, data: T) -> T:
Returns:
Representation of created instance.
"""
raise NotImplementedError
return data

async def list(self, **kwargs: Any) -> list[T]:
"""Return view of the collection of `T`.
Expand All @@ -70,7 +73,7 @@ async def list(self, **kwargs: Any) -> list[T]:
Returns:
The list of instances retrieved from the repository.
"""
raise NotImplementedError
return []

async def update(self, id_: Any, data: T) -> T:
"""Update existing instance of `T` with `data`.
Expand All @@ -82,7 +85,7 @@ async def update(self, id_: Any, data: T) -> T:
Returns:
Updated representation.
"""
raise NotImplementedError
return data

async def upsert(self, id_: Any, data: T) -> T:
"""Create or update an instance of `T` with `data`.
Expand All @@ -94,7 +97,7 @@ async def upsert(self, id_: Any, data: T) -> T:
Returns:
Updated or created representation.
"""
raise NotImplementedError
return data

async def get(self, id_: Any) -> T:
"""Retrieve a representation of `T` with that is identified by `id_`
Expand All @@ -105,7 +108,7 @@ async def get(self, id_: Any) -> T:
Returns:
Representation of instance with identifier `id_`.
"""
raise NotImplementedError
raise NotFoundError

async def delete(self, id_: Any) -> T:
"""Delete `T` that is identified by `id_`.
Expand All @@ -116,7 +119,7 @@ async def delete(self, id_: Any) -> T:
Returns:
Representation of the deleted instance.
"""
raise NotImplementedError
raise NotFoundError

async def enqueue_background_task(self, method_name: str, **kwargs: Any) -> None:
"""Enqueue an async callback for the operation and data.
Expand Down