method

On this page

method#

method(function: Callable[[MetadataGenerator], Any], *, items: list[str] | None = None, name_mapping: Mapping[str, str] | None = None) MetadataMethod#
method(function: None = None, *, items: list[str] | None = None, name_mapping: Mapping[str, str] | None = None) Callable[[Callable], MetadataMethod]

Decorator that turns methods into metadata method.

Can be used as @method or @method(items=..., ...).

Parameters:
  • function – Takes a MetadataGenerator instance and return either a single value (that will be given the same name as the method) or a mapping of multiple items.

  • items – If the method return a mapping of multiple items, specify their names.

  • name_mapping – Mapping to rename items ({"item_name": "new_name"}).