Skip to content

Draft: Update properties to use new LabThings syntax

The new form of Properties currently under consideration in labthings-fastapi#155 changes how properties and settings are defined. This MR updates the microscope codebase to use the new syntax, allowing us to test that the LabThings changes have not caused any problems. I don't anticipate this will be an issue as, while the syntax has changed, I believe the functionality we were using has not changed.

This should play nicely with mypy, and paves the way for more improvements in LabThings. It means properties of Things are now typed. Typing is not yet implemented on DirectThingClient subclasses, but that's planned.

I don't expect this will be merged: it is very likely that there will be too many conflicts before LabThings is released. However, I agreed to do this before we merge the branch in LabThings so we could check it.

This MR contains the following

  • Update to use the new LabThings syntax:
    • @lt.thing_property is renamed to @lt.property
    • @lt.thing_setting is renamed to@lt.setting
    • ThingProperty now uses a type hint on the class attribute, which should play better with type checking.
      prop = lt.ThingProperty(int, initial_value=10, readonly=True)
      becomes
      prop: int= lt.property(default=10, readonly=True)
    • A similar change is applied to ThingSetting -> setting.
    • The observable argument is removed.
  • Update linter settings to work with the new syntax
  • Modify pyproject.toml to use LabThings from the merge request branch. This should be reverted before merge.

Merge checklist:

  • [ ] All new/changed functions have up to date typehints and docstrings
  • [ ] Any UI updates have a before and after screenshot in the MR description
  • [ ] Unit testing of new functionality has similar or better coverage that similar existing code
  • This code has been tested on a microscope
    • [ ] With webapp has been recompiled (if changed)
    • [ ] With updated settings JSON (if changed)
    • SmartScan and live stitching work
Edited by Julian Stirling

Merge request reports

Loading