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 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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue