code: def complete_leaf_value(
      return_type,  # type: Union[GraphQLEnumType, GraphQLScalarType]
      path,  # type: List[Union[int, str]]
      result,  # type: Any
  ):
      # type: (...) -> Union[int, str, float, bool]
      
      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
docs: Complete a Scalar or Enum by serializing to a valid value, returning null if serialization is not possible.