Skip to content

DeviceRef inherits from str which leads to confusion on the client #1556

Closed

Description

@oliwenmandiamond

When using the BlueapiClient, if I check the avaliable methods for a device, it will give me the following results:

>>> devs.ew4000
Device(ew4000)
>>> devs.ew4000.
devs.ew4000.capitalize()    devs.ew4000.index(          devs.ew4000.isspace()       devs.ew4000.removeprefix(   devs.ew4000.splitlines(
devs.ew4000.casefold()      devs.ew4000.isalnum()       devs.ew4000.istitle()       devs.ew4000.removesuffix(   devs.ew4000.startswith(
devs.ew4000.center(         devs.ew4000.isalpha()       devs.ew4000.isupper()       devs.ew4000.replace(        devs.ew4000.strip(
devs.ew4000.count(          devs.ew4000.isascii()       devs.ew4000.join(           devs.ew4000.rfind(          devs.ew4000.swapcase()
devs.ew4000.encode(         devs.ew4000.isdecimal()     devs.ew4000.ljust(          devs.ew4000.rindex(         devs.ew4000.title()
devs.ew4000.endswith(       devs.ew4000.isdigit()       devs.ew4000.lower()         devs.ew4000.rjust(          devs.ew4000.translate(
devs.ew4000.expandtabs(     devs.ew4000.isidentifier()  devs.ew4000.lstrip(         devs.ew4000.rpartition(     devs.ew4000.upper()
devs.ew4000.find(           devs.ew4000.islower()       devs.ew4000.maketrans(      devs.ew4000.rsplit(         devs.ew4000.zfill(
devs.ew4000.format(         devs.ew4000.isnumeric()     devs.ew4000.model           devs.ew4000.rstrip(
devs.ew4000.format_map(     devs.ew4000.isprintable()   devs.ew4000.partition(      devs.ew4000.split(

When the only methods which should be available to the user are the ones we expose e.g model I think is the only one that should be available so they can check the device bluesky protocols. These extra methods come from class DeviceRef inheriting str and is rather confusing. It is done this way so that when passing the "device" to the plan, the device is treated as the device name for the server to lookup.

Acceptance Criteria

  • DeviceRef no longer inherits from str.

Activity

  1. tpoliaw commented on Jun 12, 2026

    @tpoliaw
    Contributor

    This was originally done to make the json serialization straightforward as it is handled by the requests library where we can't change behaviour. A possible approach to this would be to handle the json serialization on our side and pass the string to the request as data. We could then use a default handler to support DeviceRef types.

  2. self-assigned this
    on Jun 12, 2026
  3. linked a pull request that will close this issuerefactor: Stop DeviceRef extending str #1557on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions