Skip to content

Commit

Permalink
modify(inMemoryRepository): variabilize exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Saucisse à roulettes committed Jun 11, 2023
1 parent f4ea37b commit ad9be69
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ppa/in_memory.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from typing import Any, Type


def in_memory_repository(cls) -> Type:
def in_memory_repository(cls, entity_already_exists_exception: Type[Exception], entity_not_found_exception: Type[Exception]) -> Type:

e_already_exists = entity_already_exists_exception
e_not_found = entity_not_found_exception
class InMemoryRepository:
find_by_fields: list[str] = ["id"]
entity_already_exists_exception: Type[Exception] = ValueError
entity_not_found_exception: Type[Exception] = ValueError
entity_already_exists_exception: Type[Exception] = e_already_exists
entity_not_found_exception: Type[Exception] = e_not_found

def __init__(self) -> None:
self._store: dict[str, Any] = {}
Expand Down

0 comments on commit ad9be69

Please sign in to comment.