Skip to content

Classes that only extend Device aren't treated as BlueskyDevices #1369

Closed

Description

@tpoliaw

If a plan accepts a parameter that is typed as a class that extends only Device but not any of the bluesky protocols, it is not recognised as a bluesky device and doesn't have the reference type added that supports passing devices by name.

from ophyd_async.core import Device

class Demo(Device):
    pass

def sample_plan(demo: Demo) -> MsgGenerator:
    yield from []

When trying to run this plan using a string name as the argument for demo, the error returned will be of the form Input should be an instance of Demo instead of the expected Value error, Device demo is not of type sample_plans.Demo.

Activity

  1. tpoliaw commented on Jan 30, 2026

    @tpoliaw
    ContributorAuthor

    I think this is down to a difference in how Protocols work compared to classes in the isinstance test.

    >>> from typing import Protocol, runtime_checkable
    ...
    ... @runtime_checkable
    ... class Proto(Protocol):
    ...     def proto_method(self):...
    ...
    ... class Base:
    ...     pass
    ...
    ... class Foo(Proto):
    ...     pass
    ...
    ... class Bar(Base):
    ...     pass
    ...
    >>> isinstance(Foo, Proto)
    True
    >>> isinstance(Bar, Base)
    False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions