diff --git a/src/repository_orm/adapters/abstract.py b/src/repository_orm/adapters/abstract.py index 5d24a2e..38e9dcd 100644 --- a/src/repository_orm/adapters/abstract.py +++ b/src/repository_orm/adapters/abstract.py @@ -1,10 +1,12 @@ """Define the interface of the repositories.""" import abc -from typing import Dict, List, Type, Union +from typing import Dict, List, Type, TypeVar, Union from ..exceptions import EntityNotFoundError -from ..model import Entity +from ..model import Entity as EntityModel + +Entity = TypeVar("Entity", bound=EntityModel) class AbstractRepository(abc.ABC): diff --git a/tests/integration/test_repository.py b/tests/integration/test_repository.py index f5a1659..1128194 100644 --- a/tests/integration/test_repository.py +++ b/tests/integration/test_repository.py @@ -114,9 +114,7 @@ def test_repository_can_save_an_entity_without_id( saved_entity = repo.last(type(inserted_entity)) assert saved_entity.id_ == inserted_entity.id_ + 1 - # ignore: Entity doesn't have a name attribute, but all the models in the test - # cases do. - assert saved_entity.name == "Entity without id" # type: ignore + assert saved_entity.name == "Entity without id" def test_repository_cant_save_an_entity_with_a_negative_id( @@ -135,9 +133,7 @@ def test_repository_cant_save_an_entity_with_a_negative_id( saved_entity = repo.last(type(inserted_entity)) assert saved_entity.id_ == inserted_entity.id_ + 1 - # ignore: Entity doesn't have a name attribute, but all the models in the test - # cases do. - assert saved_entity.name == "Entity with negative id" # type: ignore + assert saved_entity.name == "Entity with negative id" def test_repo_add_entity_is_idempotent(