Skip to content

Raise an error if settings are used before they have been loaded #115

@rwb27

Description

@rwb27

Is your feature request related to a problem? Please describe.
As of #110, settings are available before the Thing is attached to a ThingServer, but their values may be overwritten once it is attached. This has the potential to be quite confusing.

Describe the solution you'd like
Reading or writing ThingSetting descriptors on a Thing that is not attached to a ThingServer should raise an error. There should be a clear and simple way to silence the error (e.g. for tests, or if the author is confident they want the current behaviour).

Additional context
Thing subclasses should not do very much in __init__ beyond setting defaults and remembering initialisation arguments, because it's not appropriate to communicate with hardware before __enter__ is called. However, this is not currently enforced. If settings are manipulated during __init__ they may change unexpectedly between __init__ and __enter__, which could cause confusion. I think it might help catch code with the potential to get confusing if an error is raised when settings are used before __enter__.

Metadata

Metadata

Assignees

No one assigned

    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