Property#

class caput.config.Property(default: Any | None = None, proptype: collections.abc.Callable | None = None, key: str | None = None, deprecated: bool = False)[source]#

Custom property descriptor that can load values from a given dict.

Parameters:
defaultAny | None, optional

The initial value for the property.

proptypeCallable | None, optional

The type of the property. This is a function which gets called whenever we update the value: val = proptype(newval), so it can be used for conversion and validation. This convention also means that we can use the standard type functions as prototypes.

keystr | None, optional

The name of the dictionary key that we can fetch this value from. If None (default), attempt to use the attribute name from the class.

deprecatedbool, optional

Flag a property as deprecated. This will raise a deprecation warning when first accessed, but will not change the behaviour of this Property instance.