Browse Source

Allow ValueObject for Repository subclasses (#19)

Casper van der Wel 1 năm trước cách đây
mục cha
commit
db5105a71f
2 tập tin đã thay đổi với 3 bổ sung5 xóa
  1. 1 1
      CHANGES.md
  2. 2 4
      clean_python/base/domain/repository.py

+ 1 - 1
CHANGES.md

@@ -4,7 +4,7 @@
 0.6.4 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Allow value objects for `Repository` subclasses.
 
 
 0.6.3 (2023-10-02)

+ 2 - 4
clean_python/base/domain/repository.py

@@ -14,13 +14,13 @@ from .gateway import Gateway
 from .gateway import SyncGateway
 from .pagination import Page
 from .pagination import PageOptions
-from .root_entity import RootEntity
 from .types import Id
 from .types import Json
+from .value_object import ValueObject
 
 __all__ = ["Repository", "SyncRepository"]
 
-T = TypeVar("T", bound=RootEntity)
+T = TypeVar("T", bound=ValueObject)
 
 
 class Repository(Generic[T]):
@@ -32,7 +32,6 @@ class Repository(Generic[T]):
     def __init_subclass__(cls) -> None:
         (base,) = cls.__orig_bases__  # type: ignore
         (entity,) = base.__args__
-        assert issubclass(entity, RootEntity)
         super().__init_subclass__()
         cls.entity = entity
 
@@ -108,7 +107,6 @@ class SyncRepository(Generic[T]):
     def __init_subclass__(cls) -> None:
         (base,) = cls.__orig_bases__  # type: ignore
         (entity,) = base.__args__
-        assert issubclass(entity, RootEntity)
         super().__init_subclass__()
         cls.entity = entity