Class and function decorators.
attach_fields( *args, on_conflict='raise' )
Class decorator to attach field properties in a Records class.
dtype and other relevant information from Records.field_config and map its fields as properties. This behavior can be changed by using
config should contain fields (keys) and dictionaries (values) with the following keys:
attach: Whether to attach the field property. Can be provided as a string to be used as a target attribute name. Defaults to True.
defaults: Dictionary with default keyword arguments for Records.map_field(). Defaults to an empty dict.
attach_filters: Whether to attach filters based on the field's values. Can be provided as a dict to be used instead of the mapping (filter value -> target filter name). Defaults to False. If True, defaults to
filter_defaults: Dictionary with default keyword arguments for Records.apply_mask(). Can be provided by target filter name. Defaults to an empty dict.
on_conflict: Overrides global
on_conflictfor both field and filter properties.
Any potential attribute name is prepared by placing underscores between capital letters and converting to the lower case.
If an attribute with the same name already exists in the class but the name is not listed in the field config:
- it will be overridden if
- it will be ignored if
- an error will be raised if
override_field_config( *args, merge_configs=True )
Class decorator to override field configs of all base classes in MRO that subclass Records.
Instead of overriding
_field_config class attribute, you can pass
config directly to this decorator.
merge_configs to not merge, which will effectively disable field inheritance.