Skip to content

decorators.property_field

property_field

1
property_field(func: Callable) -> Union[property, Callable]

Decorator to set a property like function on Model to be exposed as field in dict() and fastapi response. Although you can decorate a @property field like this and this will work, mypy validation will complain about this. Note that "fields" exposed like this do not go through validation.

Raises:

  • ModelDefinitionError: if method has any other argument than self.

Arguments:

  • func: decorated function to be exposed :type func: Callable

Returns:

decorated function passed in func param, with set property_field = True :rtype: Union[property, Callable]