Tagging: Metadata on fields and values#
Fiddle allows annotating fields of Config’s (and Buildable’s more
generally) and values within a Fiddle configuration DAG with metadata called
Tag’s. Tags make bulk update of values easy, and reduces coupling between a
library and its configuration.
Tagging Values#
- fiddle.TaggedValue(tags, default=fdl.NO_VALUE)[source]#
Declares a value annotated with a set of
Tag’s.This is now basically a fdl.Config(lambda value: value) configuration, since tags can be set on any field.
- Parameters:
tags (
Collection[TagType]) – Set of tags to apply.default (
Union[NoValue,TypeVar(T)]) – Default value to the identity function.
- Return type:
TaggedValueCls[TypeVar(T)]- Returns:
Tagged value configuration object.
- Raises:
ValueError – If tags is empty.
- class fiddle.tagging.TaggedValueCls(fn_or_cls, /, *args, **kwargs)[source]#
Placeholder class for TaggedValue instances.
Instances of this class are generally transitory; when passed as an argument of a Fiddle Buildable, will be expanded into that argument’s values and tags. However, they may survive as stand-alone objects within tuples, lists, and dictionaries.
Tagging Errors#
Tag Type#
- class fiddle.tag_type.TagType(name, bases, dct)[source]#
All Fiddle tags are instances of this class.
For defining Tags, we leverage Python’s class definition and documentation syntax.
See the documentation on fdl.Tag for instructions on how to use.
- property description: str#
A string describing the semantics and intended usecases for this tag.
- property name: str#
A unique name for this tag.