Skip to content

Commit

Permalink
Fix dialyzer warnings (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Usseglio Viretta authored and José Valim committed Jan 13, 2020
1 parent 8413b4d commit 7538d86
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/gettext.ex
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ defmodule Gettext do
Gettext.dgettext(MyApp.Gettext, "errors", "signup form", "%{name} is not a valid name", name: "Meg")
#=> "Meg non è un nome valido"
"""
@spec dpgettext(module, binary, binary, binary, bindings) :: binary
@spec dpgettext(module, binary, binary | nil, binary, bindings) :: binary
def dpgettext(backend, domain, msgctxt, msgid, bindings) when is_list(bindings) do
dpgettext(backend, domain, msgctxt, msgid, Map.new(bindings))
end
Expand Down Expand Up @@ -816,7 +816,8 @@ defmodule Gettext do
#=> "Errore"
"""
@spec dpngettext(module, binary, binary, binary, binary, non_neg_integer, bindings) :: binary
@spec dpngettext(module, binary, binary | nil, binary, binary, non_neg_integer, bindings) ::
binary
def dpngettext(backend, domain, msgctxt, msgid, msgid_plural, n, bindings \\ %{})

def dpngettext(backend, domain, msgctxt, msgid, msgid_plural, n, bindings)
Expand Down
4 changes: 2 additions & 2 deletions lib/gettext/extractor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,6 @@ defmodule Gettext.Extractor do
"plural translation with msgid '#{IO.iodata_to_binary(t.msgid)}' has a non-empty msgstr"
end

defp blank?(nil), do: true
defp blank?(str), do: IO.iodata_length(str) == 0
defp blank?(str) when not is_nil(str), do: IO.iodata_length(str) == 0
defp blank?(_), do: true
end
1 change: 0 additions & 1 deletion lib/gettext/merger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ defmodule Gettext.Merger do
over the new PO file as they're meant to be comments generated by tools or
comments directed to developers.
"""
@spec new_po_file(Path.t(), Path.t(), String.t(), Keyword.t()) :: iodata
def new_po_file(po_file, pot_file, locale, opts) when is_binary(locale) and is_list(opts) do
pot = PO.parse_file!(pot_file)
opts = put_plural_forms_opt(opts, pot.headers, locale)
Expand Down
6 changes: 3 additions & 3 deletions lib/gettext/po/plural_translation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule Gettext.PO.PluralTranslation do

@type t :: %__MODULE__{
msgid: [binary],
msgid_plural: [binary],
msgid_plural: [binary] | nil,
msgstr: %{non_neg_integer => [binary]},
msgctxt: [binary] | nil,
comments: [binary],
Expand All @@ -45,11 +45,11 @@ defmodule Gettext.PO.PluralTranslation do

defstruct msgid: nil,
msgid_plural: nil,
msgstr: nil,
msgstr: [],
msgctxt: nil,
comments: [],
extracted_comments: [],
references: [],
flags: MapSet.new(),
po_source_line: nil
po_source_line: 1
end
4 changes: 2 additions & 2 deletions lib/gettext/po/translation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ defmodule Gettext.PO.Translation do
@enforce_keys [:msgid]

defstruct msgid: nil,
msgstr: nil,
msgstr: [],
msgctxt: nil,
comments: [],
extracted_comments: [],
references: [],
flags: MapSet.new(),
po_source_line: nil
po_source_line: 1
end

0 comments on commit 7538d86

Please sign in to comment.