From 2a2453f9d6affdc231ec4d782e66ecf2c95c841e Mon Sep 17 00:00:00 2001 From: Rebecca Le <543859+sevenseacat@users.noreply.github.com> Date: Thu, 13 May 2021 16:42:34 +0800 Subject: [PATCH] Update typespec for `Cloudex.upload/2` When passing in a single string, it can only ever return a single result. A list of strings will return a list of results --- lib/cloudex.ex | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/cloudex.ex b/lib/cloudex.ex index 3f03344..c415726 100644 --- a/lib/cloudex.ex +++ b/lib/cloudex.ex @@ -12,16 +12,13 @@ defmodule Cloudex do @spec start(settings :: map) :: {:ok, pid} defdelegate start(settings), to: Cloudex.Settings - @type upload_result :: - {:ok, Cloudex.UploadedImage.t()} - | {:error, any} - | [{:ok, Cloudex.UploadedImage.t()} | {:error, any}] + @type upload_result :: {:ok, Cloudex.UploadedImage.t()} | {:error, any} @doc ~S""" Uploads a (list of) image file(s) and/or url(s) to cloudinary """ - @spec upload(list | String.t()) :: upload_result - @spec upload(list | [String.t()], map) :: upload_result + @spec upload(list | String.t(), map) :: upload_result + @spec upload(list | [String.t()], map) :: [upload_result] def upload(list, options \\ %{}) do sanitized_list = sanitize_list(list) invalid_list = Enum.filter(sanitized_list, &match?({:error, _}, &1))