Closed rosesyrett closed 1 year ago
I'm getting the following, seemingly unrelated, mypy errors:
(venv) rose@rose-Precision-3560:~/Documents/projects/ophyd$ mypy ophyd/v2/
ophyd/v2/core.py:805: error: Incompatible return value type (got "Union[Status, List[Any]]", expected "List[Any]") [return-value]
ophyd/v2/core.py:811: error: Incompatible return value type (got "Union[Status, List[Any]]", expected "List[Any]") [return-value]
ophyd/v2/core.py:888: error: Argument 1 to "__iadd__" of "list" has incompatible type "Union[Status, List[Any]]"; expected "Iterable[StandardReadable]" [arg-type]
ophyd/v2/core.py:896: error: Argument 1 to "__iadd__" of "list" has incompatible type "Union[Status, List[Any]]"; expected "Iterable[StandardReadable]" [arg-type]
Found 4 errors in 1 file (checked 9 source files)
^ can confirm that I get these errors even on the master branch... I will # type: ignore
them for now.
^ can confirm that I get these errors even on the master branch... I will
# type: ignore
them for now.
They will be fixed by #1123
The docs are failing to build because of the changes made here... Specifically, the epics_demo.py in docs/user_v2/examples is failing.
Run it with ipython ipython -i docs/user_v2/examples/epics_demo.py
and just type in,
RE(mov(samp.x, 100))
RE(mov(samp.x, 100))
The second invocation will fail with the assertion error;
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
File /usr/lib/python3.10/asyncio/tasks.py:408, in wait_for(fut, timeout)
407 if timeout is None:
--> 408 return await fut
410 if timeout <= 0:
File ~/Documents/projects/ophyd/ophyd/v2/epicsdemo/__init__.py:70, in Mover._move(self, new_position, watchers)
69 await self.setpoint.set(new_position, wait=False)
---> 70 async for current_position in observe_value(self.readback):
71 for watcher in watchers:
File ~/Documents/projects/ophyd/ophyd/v2/core.py:729, in observe_value(signal)
728 q: asyncio.Queue[T] = asyncio.Queue()
--> 729 signal.subscribe_value(q.put_nowait)
730 try:
File ~/Documents/projects/ophyd/ophyd/v2/core.py:670, in SignalR.subscribe_value(self, function)
669 """Subscribe to updates in value of a device"""
--> 670 self._get_cache().subscribe(function, want_value=True)
File ~/Documents/projects/ophyd/ophyd/v2/core.py:645, in SignalR._get_cache(self)
644 if not self._cache:
--> 645 self._cache = _SignalCache(self._backend, self)
646 return self._cache
File ~/Documents/projects/ophyd/ophyd/v2/core.py:573, in _SignalCache.__init__(self, backend, signal)
572 self.backend = backend
--> 573 backend.set_callback(self._callback)
File ~/Documents/projects/ophyd/ophyd/v2/_aioca.py:224, in CaSignalBackend.set_callback(self, callback)
223 if callback:
--> 224 assert (
225 not self.subscription
226 ), "Cannot set a callback when one is already set"
227 self.subscription = camonitor(
228 self.read_pv,
229 lambda v: callback(self.converter.reading(v), self.converter.value(v)),
230 datatype=self.converter.read_dbr,
231 format=FORMAT_TIME,
232 )
simple PR to remove
Monitor
andSimMonitor
from ophyd/v2/core.py.It has been agreed that it makes sense if the backend only keeps track of one single callback. Therefore, we no longer need a
Monitor
to keep track of potentially several callbacks.