labthings / labthings/labthings-fastapi
Raise an error if settings are used before they have been loaded
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
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__.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing Thing and ThingSetting descriptor access through attachment and enter, since the issue names those entry points but no files or tests. Define how premature reads and writes should fail, how the opt-out should work, and what tests demonstrate both the error and intentional current behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100