Skip to content

Commit

Permalink
Fix type spec of Mailer.deliver_later/1 (#584)
Browse files Browse the repository at this point in the history
What changed?
============

This commit updates the `Mailer.deliver_later/1` `@spec` for the
function found in `__using__`. It seems to not have been updated
with the release of Bamboo 2.0. 

Why?
-----

After updating to 2.0.0, dialyzer fails with a message like this:

lib/my_app/mailer/mailgun.ex:17:invalid_contract
The @SPEC for the function does not match the success typing of the function.

Function:
MyApp.Mailer.Mailgun.BambooMailer.deliver_later/1

Success typing:
@SPEC deliver_later(_) ::
  {:error,
   <<_::64, _::size(8)>>
   | %{
       :__exception__ => true,
       :__struct__ => Bamboo.EmptyFromAddressError | Bamboo.NilRecipientsError,
       :message => <<_::64, _::size(8)>>
     }}
  | {:ok,
     %{
       :bcc => {binary(), binary()},
       :cc => {binary(), binary()},
       :from => {binary(), binary()},
       :to => {binary(), binary()},
       _ => _
     }}

________________________________________________________________________________
done (warnings were emitted)
  • Loading branch information
lasseebert committed Feb 23, 2021
1 parent 9e13937 commit 6636983
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/bamboo/mailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ defmodule Bamboo.Mailer do
Bamboo.Mailer.deliver_now!(config.adapter, email, config, opts)
end

@spec deliver_later(Bamboo.Email.t()) :: Bamboo.Email.t()
@spec deliver_later(Bamboo.Email.t()) ::
{:ok, Bamboo.Email.t()} | {:error, Exception.t() | String.t()}
def deliver_later(email, opts \\ []) do
config = build_config(opts)
Bamboo.Mailer.deliver_later(config.adapter, email, config)
Expand Down

0 comments on commit 6636983

Please sign in to comment.