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