<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def complete_leaf_value( return_type, # type: Union[GraphQLEnumType, GraphQLScalarType] path, # type: List[Union[int, str]] result, # type: Any ):
 """ Complete a Scalar or Enum by serializing to a valid value, returning null if serialization is not possible. """

    assert hasattr(return_type, "serialize"), "Missing serialize method on type"
    serialized_result = return_type.serialize(result)

    if serialized_result is None:
        raise GraphQLError(
            ('Expected a value of type "{}" but ' + "received: {}").format(
                return_type, result
            ),
            path=path,
        )
    return serialized_result