33import asyncio
44from collections .abc import Callable
55from enum import Enum
6- from typing import Any , Generic , Protocol , runtime_checkable
6+ from typing import Any , Generic
77
88import fastcs
99
@@ -18,34 +18,30 @@ class AttrMode(Enum):
1818 READ_WRITE = 3
1919
2020
21- @runtime_checkable
22- class Sender (Protocol ):
23- """Protocol for setting the value of an ``Attribute``."""
24-
21+ class _BaseHandler :
2522 async def initialise (self , controller : fastcs .controller .BaseController ) -> None :
2623 pass
2724
25+
26+ class Setter (_BaseHandler ):
27+ """Protocol for setting the value of an ``Attribute``."""
28+
2829 async def put (self , attr : AttrW [T ], value : T ) -> None :
2930 pass
3031
3132
32- @runtime_checkable
33- class Updater (Protocol ):
33+ class Updater (_BaseHandler ):
3434 """Protocol for updating the cached readback value of an ``Attribute``."""
3535
3636 # If update period is None then the attribute will not be updated as a task.
3737 update_period : float | None = None
3838
39- async def initialise (self , controller : fastcs .controller .BaseController ) -> None :
40- pass
41-
4239 async def update (self , attr : AttrR ) -> None :
4340 pass
4441
4542
46- @runtime_checkable
47- class Handler (Sender , Updater , Protocol ):
48- """Protocol encapsulating both ``Sender`` and ``Updater``."""
43+ class Handler (Setter , Updater ):
44+ """Protocol encapsulating both ``Setter`` and ``Updater``."""
4945
5046 pass
5147
@@ -179,7 +175,7 @@ def __init__(
179175 datatype : DataType [T ],
180176 access_mode = AttrMode .WRITE ,
181177 group : str | None = None ,
182- handler : Sender | None = None ,
178+ handler : Setter | None = None ,
183179 description : str | None = None ,
184180 ) -> None :
185181 super ().__init__ (
@@ -193,9 +189,9 @@ def __init__(
193189 self ._write_display_callbacks : list [AttrCallback [T ]] | None = None
194190
195191 if handler is not None :
196- self ._sender = handler
192+ self ._setter = handler
197193 else :
198- self ._sender = SimpleHandler ()
194+ self ._setter = SimpleHandler ()
199195
200196 async def process (self , value : T ) -> None :
201197 await self .process_without_display_update (value )
@@ -225,8 +221,8 @@ def add_write_display_callback(self, callback: AttrCallback[T]) -> None:
225221 self ._write_display_callbacks .append (callback )
226222
227223 @property
228- def sender (self ) -> Sender :
229- return self ._sender
224+ def sender (self ) -> Setter :
225+ return self ._setter
230226
231227
232228class AttrRW (AttrR [T ], AttrW [T ]):
0 commit comments