forked from p15670423/monkey
Island: Use TypeVar for IEventRepository.get_events_by_type()
This commit is contained in:
parent
c54d1b89ab
commit
c977d8c212
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue