parameters: (value, expected_type, path, context)
docstring: Converts `value` to a value with any of the types in `expected_type`.
docstring_summary: Converts `value` to a value with any of the types in `expected_type`.
docstring_tokens: Converts value to a value with any of the types in expected_type .
function: def _convert_union(value, expected_type, path, context):
    """Converts `value` to a value with any of the types in `expected_type`."""
    for type_option in type_annotations.get_generic_type_args(expected_type):
      try:
        return _convert_value(value, type_option, path, context)
      except TypeError:
        pass
    raise TypeError(f'{"".join(path)}: expected {expected_type}, got {value!r}')
function_tokens: def _convert_union ( value , expected_type , path , context ) : for type_option in type_annotations . get_generic_type_args ( expected_type ) : try : return _convert_value ( value , type_option , path , context ) except TypeError : pass raise TypeError ( f'{"".join(path)}: expected {expected_type}, got {value!r}' )