Skip to content

Commit

Permalink
Fix lists in shared_repo's typespecs
Browse files Browse the repository at this point in the history
Multiple instances of `list(atom() | atom())`, which would be a list
containing atoms and also atoms.

Rather than correcting to `list(atom()) | atom()`, use `[atom()] | atom()`
to avoid getting parentheses hypnosis.
  • Loading branch information
waisbrot committed Oct 26, 2017
1 parent baa0677 commit e6898e3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/open_pantry/web/models/shared_repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule OpenPantry.SharedRepo do
@spec find(integer()) :: __MODULE__.t | nil
def find(id) when is_integer(id), do: query(id) |> Repo.one!

@spec find(integer(), list(atom()) | atom()) :: __MODULE__.t | nil
@spec find(integer(), [atom()] | atom()) :: __MODULE__.t | nil
def find(id, preload) when is_integer(id) do
query(id, preload) |> Repo.one!
end
Expand All @@ -19,7 +19,7 @@ defmodule OpenPantry.SharedRepo do
all([])
end

@spec all(list(atom())) :: list(__MODULE__.t) | []
@spec all([atom()] | atom()) :: list(__MODULE__.t) | []
def all(preload) do
query_all(preload) |> Repo.all
end
Expand All @@ -29,7 +29,7 @@ defmodule OpenPantry.SharedRepo do
query_all([])
end

@spec query_all(list(atom() | atom())) :: Ecto.Query.t
@spec query_all([atom()] | atom()) :: Ecto.Query.t
def query_all(preload) do
from(_struct in __MODULE__,
preload: ^preload)
Expand All @@ -40,7 +40,7 @@ defmodule OpenPantry.SharedRepo do
from(struct in __MODULE__,
where: struct.id == ^id)
end
@spec query(integer(), list(atom() | atom())) :: Ecto.Query.t
@spec query(integer(), [atom()] | atom()) :: Ecto.Query.t
def query(id, preload) when is_integer(id) do
from(struct in __MODULE__,
where: struct.id == ^id,
Expand All @@ -50,4 +50,4 @@ defmodule OpenPantry.SharedRepo do
end
end

end
end

0 comments on commit e6898e3

Please sign in to comment.