2323"""
2424
2525from abc import ABC, abstractmethod
26- from collections import defaultdict
27- from collections.abc import Awaitable, Callable, Collection, Sequence
28- from functools import partial
26+ from collections.abc import Awaitable, Callable
2927from typing import (
3028 TYPE_CHECKING,
3129 Any,
32- Protocol,
3330 TypeAlias,
3431 TypeVar,
35- cast,
36- runtime_checkable,
3732)
3833
3934from ..app.event_emitter import Event
4035from ..utils import MISSING, Undefined
41- from ..utils.annotations import get_annotations
42- from ..utils.private import hybridmethod
36+
37+ if TYPE_CHECKING:
38+ from .gear import EventListener
4339
4440E = TypeVar("E", bound="Event", covariant=True)
4541
@@ -55,12 +51,15 @@ def add_listener(
5551 event: type[E] | Undefined = MISSING,
5652 is_instance_function: bool = False,
5753 once: bool = False,
58- ) -> None : ...
54+ ) -> "EventListener[E]" : ...
5955
6056 @abstractmethod
6157 def remove_listener(
62- self, callback: EventCallback[E], event: type[E] | Undefined = MISSING, is_instance_function: bool = False
58+ self,
59+ listener: "EventListener[E]",
60+ event: type[E] | Undefined = MISSING,
61+ is_instance_function: bool = False,
6362 ) -> None: ...
6463
6564 @abstractmethod
66- def listen(self, *args: Any, **kwargs: Any) -> Callable[[Callable[[E], Awaitable[None]]], EventCallback[E]] : ...
65+ def listen(self, *args: Any, **kwargs: Any) -> Any : ...
0 commit comments