Island: Use TypeVar for IEventRepository.get_events_by_type()

This commit is contained in:
Mike Salvatore 2022-09-14 09:41:58 -04:00
parent c54d1b89ab
commit c977d8c212
1 changed files with 4 additions and 4 deletions

View File

@ -1,9 +1,11 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Sequence, Type from typing import Sequence, Type, TypeVar
from common.events import AbstractAgentEvent from common.events import AbstractAgentEvent
from common.types import AgentID from common.types import AgentID
T = TypeVar("T", bound=AbstractAgentEvent)
class IEventRepository(ABC): class IEventRepository(ABC):
"""A repository used to store and retrieve event objects""" """A repository used to store and retrieve event objects"""
@ -27,9 +29,7 @@ class IEventRepository(ABC):
""" """
@abstractmethod @abstractmethod
def get_events_by_type( def get_events_by_type(self, event_type: Type[T]) -> Sequence[T]:
self, event_type: Type[AbstractAgentEvent]
) -> Sequence[AbstractAgentEvent]:
""" """
Retrieve all events with same type Retrieve all events with same type