labthings_fastapi.thing_class_settings
Settings that control how a lt.Thing interacts with LabThings.
This module defines the type used by lt.Thing._class_settings to control
how it interacts with LabThings. Most of this module is intended for internal
use: the only user-facing item is the type ThingClassSettings
Attributes
Classes
Settings that define how a Thing operates. |
Functions
|
Validate a class settings dict. |
|
Retrieve a class settings dict or default to an empty dict. |
|
Determine whether properties should perform validation when set from Python. |
Module Contents
- class labthings_fastapi.thing_class_settings.ThingClassSettings
Bases:
TypedDictSettings that define how a Thing operates.
Initialize self. See help(type(self)) for accurate signature.
- validate_properties_on_set: ReadOnly[bool]
Whether property values are validated when set from Python.
This is not yet enabled by default, but will be in future. A
DeprecationWarningwill be raised if it is not set toTrue.
- labthings_fastapi.thing_class_settings.SETTINGS_TYPEADAPTER
- labthings_fastapi.thing_class_settings.validate_thing_class_settings(cls: type[Thing]) None
Validate a class settings dict.
This retrieves the dict from the class, and ensures the attribute is a valid
ThingClassSettingstyped dict.- Parameters:
cls – The
Thingsubclass where we are validating.- Raises:
InvalidClassSettingsError – if the dictionary is not valid.
- labthings_fastapi.thing_class_settings.get_class_settings(cls: type[Thing]) ThingClassSettings
Retrieve a class settings dict or default to an empty dict.
- Parameters:
cls – The class from which to retrieve the dict.
- Returns:
The
_class_settingsdict, or an empty dict.- Raises:
TypeError – if the settings is not a dictionary.
- labthings_fastapi.thing_class_settings.get_validate_properties_on_set(cls: type[Thing]) bool
Determine whether properties should perform validation when set from Python.
Note
Check that the default value defined here matches the docstring for
ThingClassSettings.- Parameters:
cls – the
Thingsubclass on which the property is defined.- Returns:
whether validation should be performed.