Skip to content

mode.types.signals

Type classes for mode.signals.

BaseSignalT

Bases: Generic[T]

Base type for all signals.

Source code in mode/types/signals.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
class BaseSignalT(Generic[T]):
    """Base type for all signals."""

    name: str
    owner: Optional[Type]

    @abc.abstractmethod
    def __init__(
        self,
        *,
        name: Optional[str] = None,
        owner: Optional[Type] = None,
        loop: Optional[asyncio.AbstractEventLoop] = None,
        default_sender: Any = None,
        receivers: Optional[MutableSet[SignalHandlerRefT]] = None,
        filter_receivers: Optional[FilterReceiverMapping] = None,
    ) -> None: ...

    @abc.abstractmethod
    def clone(self, **kwargs: Any) -> "BaseSignalT": ...

    @abc.abstractmethod
    def with_default_sender(self, sender: Any = None) -> "BaseSignalT": ...

    @abc.abstractmethod
    def connect(self, fun: SignalHandlerT, **kwargs: Any) -> Callable: ...

    @abc.abstractmethod
    def disconnect(
        self, fun: SignalHandlerT, *, sender: Any = None, weak: bool = True
    ) -> None: ...

SignalT

Bases: BaseSignalT[T]

Base class for all async signals (using async def).

Source code in mode/types/signals.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
class SignalT(BaseSignalT[T]):
    """Base class for all async signals (using ``async def``)."""

    @abc.abstractmethod
    async def __call__(
        self, sender: T_contra, *args: Any, **kwargs: Any
    ) -> None: ...

    @abc.abstractmethod
    async def send(
        self, sender: T_contra, *args: Any, **kwargs: Any
    ) -> None: ...

    @typing.no_type_check
    @abc.abstractmethod
    def clone(self, **kwargs: Any) -> "SignalT": ...

    @typing.no_type_check
    @abc.abstractmethod
    def with_default_sender(self, sender: Any = None) -> "SignalT": ...

SyncSignalT

Bases: BaseSignalT[T]

Base class for all synchronous signals (using regular def).

Source code in mode/types/signals.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class SyncSignalT(BaseSignalT[T]):
    """Base class for all synchronous signals (using regular ``def``)."""

    @abc.abstractmethod
    def __call__(
        self, sender: T_contra, *args: Any, **kwargs: Any
    ) -> None: ...

    @abc.abstractmethod
    def send(self, sender: T_contra, *args: Any, **kwargs: Any) -> None: ...

    @typing.no_type_check
    @abc.abstractmethod
    def clone(self, **kwargs: Any) -> "SyncSignalT": ...

    @typing.no_type_check
    @abc.abstractmethod
    def with_default_sender(self, sender: Any = None) -> "SyncSignalT": ...