Skip to content

Commit 095f364

Browse files
committed
fix: Check if plan parameter is subclass of Device
The previous check for whether a parameter was a bluesky device (and would therefore go via the string-to-device lookup) was based on the type being an instance of one of the bluesky protocols. For a device that only extends `Device`, this check would return False and the device could not be injected. Including a check for the type being a subclass of Device allows all device subclasses to be looked up.
1 parent 7b10cc3 commit 095f364

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/blueapi/core/context.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
from .bluesky_types import (
4646
BLUESKY_PROTOCOLS,
47+
AsyncDevice,
4748
Device,
4849
Plan,
4950
PlanGenerator,
@@ -103,7 +104,11 @@ def qualified_generic_name(target: type) -> str:
103104

104105

105106
def is_bluesky_type(typ: type) -> bool:
106-
return typ in BLUESKY_PROTOCOLS or isinstance(typ, BLUESKY_PROTOCOLS)
107+
return (
108+
typ in BLUESKY_PROTOCOLS
109+
or isinstance(typ, BLUESKY_PROTOCOLS)
110+
or issubclass(typ, AsyncDevice)
111+
)
107112

108113

109114
C = TypeVar("C", covariant=True)

0 commit comments

Comments
 (0)