The attr, data, text, and tid functions' typespecs specify binary() | [binary()] as return values which causes dialyzer to fail sometimes.
I like the scoping feature; here's a possible solution: have :all be the default scope, and only send the scope option when it is :first or :first!:
@spec attr(html(), attr(), query()) :: [binary()]
def attr(html, attr, query), do: # returns all
@spec attr(html(), attr(), scope(), query()) :: binary()
def attr(html, attr, scope, query) when scope in [:first, :first!], do: # returns the first
(This would be a breaking change.)
Relatedly, we might want to update the fun() typespec on find so that it specifies a list as output. (I think that would be (Floki.html_tree() -> [binary()]).)
The
attr
,data
,text
, andtid
functions' typespecs specifybinary() | [binary()]
as return values which causes dialyzer to fail sometimes.I like the scoping feature; here's a possible solution: have
:all
be the default scope, and only send the scope option when it is:first
or:first!
:(This would be a breaking change.)
Relatedly, we might want to update the
fun()
typespec onfind
so that it specifies a list as output. (I think that would be(Floki.html_tree() -> [binary()])
.)