diff --git a/docs/source/properties.rst b/docs/source/properties.rst index 284b6be9..3abbf9fc 100644 --- a/docs/source/properties.rst +++ b/docs/source/properties.rst @@ -205,7 +205,7 @@ Note that the constraints for functional properties are set by assigning a dicti .. note:: Currently, property values are not validated when they are set directly in Python, only via HTTP. - Setting ``validate_properties_on_set = True`` in `~lt.Thing._class_settings` enables validation when they are set in Python. This may become default behaviour in the future. + Setting ``validate_properties_on_set = True`` in `~lt.Thing._class_settings` enables validation when they are set in Python. This will become default behaviour in the future. Property metadata ----------------- diff --git a/docs/source/public_api.rst b/docs/source/public_api.rst index a68ae373..b54d702a 100644 --- a/docs/source/public_api.rst +++ b/docs/source/public_api.rst @@ -328,7 +328,7 @@ This page summarises the parts of the LabThings API that should be most frequent Whether properties should be validated against their model when set from Python. Properties are always validated when set over HTTP. By default, no validation is performed when they are set from Python. - Setting this key to `True` will enable validation: this is likely to become the default in the future. + Setting this key to `True` will enable validation: this will become the default in the future. .. py:class:: ThingConfig(/, **data: Any) diff --git a/src/labthings_fastapi/thing_class_settings.py b/src/labthings_fastapi/thing_class_settings.py index 151328da..39cbe58c 100644 --- a/src/labthings_fastapi/thing_class_settings.py +++ b/src/labthings_fastapi/thing_class_settings.py @@ -89,17 +89,19 @@ def get_validate_properties_on_set(cls: "type[Thing]") -> bool: :return: whether validation should be performed. """ settings = get_class_settings(cls) - if "validate_properties_on_set" not in settings: + value = settings.get( + "validate_properties_on_set", + False, + ) + if not value: warnings.warn( DefaultWillChangeWarning( "`get_validate_properties_on_set` will become `True` by default " - "in the future. Set this property explicitly to `True` or `False` in " + "in the future, and may become the only option. " + "Set this property to `True` in " f"`{cls.__module__}.{cls.__name__}._class_settings` " "to eliminate this warning." ), stacklevel=3, ) - return settings.get( - "validate_properties_on_set", - False, - ) + return value