mt_metadata.helper_functions

This module has some general helper functions that it isn’t yet clear where they should live.

These may not be needed at all after the pydantic upgrade is fully integrated.

Functions

validate_setter_input(value, expected_class)

Takes a setter's input and makes it a list if it not.

cast_to_class_if_dict(obj, cls)

Module Contents

mt_metadata.helper_functions.validate_setter_input(value, expected_class)

Takes a setter’s input and makes it a list if it not. Then asserts that every list element is of permissible type (dict or expected class)

Parameters:
  • value (Union[Dict, Base]) – The input to the setter.

  • expected_class (Base) – Some mt_metadata class that we want the setter work with

Returns:

value – List of elements for the setter all of type expected_class or dict.

Return type:

list

mt_metadata.helper_functions.cast_to_class_if_dict(obj, cls)
Parameters:
  • obj (Union[Dict, MetadataBase]) – Either an mt_metadata object or its dict representaiton

  • cls (MetadataBase) – Some mt_metadata object that we want to get back

Return type:

either the input or the input dict cast to an mt_metadata object.