Fix dialyzer
This commit is contained in:
parent
851a1b0c19
commit
01974543a0
|
@ -5,7 +5,10 @@ defmodule JSON.LD.Compaction do
|
||||||
|
|
||||||
alias JSON.LD.{Context, Options}
|
alias JSON.LD.{Context, Options}
|
||||||
|
|
||||||
@spec compact(map | [map], map | nil, Options.convertible()) :: map
|
# TODO: Why is dialyzer ignoring the spec of context as a potential binary and
|
||||||
|
# complains about the is_binary(context) in the final cond to never match?
|
||||||
|
@dialyzer {:nowarn_function, compact: 3}
|
||||||
|
@spec compact(map | [map], map | binary | nil, Options.convertible()) :: map
|
||||||
def compact(input, context, options \\ %Options{}) do
|
def compact(input, context, options \\ %Options{}) do
|
||||||
options = Options.new(options)
|
options = Options.new(options)
|
||||||
active_context = JSON.LD.context(context, options)
|
active_context = JSON.LD.context(context, options)
|
||||||
|
|
|
@ -52,7 +52,7 @@ defmodule JSON.LD.Encoder do
|
||||||
@rdf_list to_string(RDF.uri(RDF.NS.RDF.List))
|
@rdf_list to_string(RDF.uri(RDF.NS.RDF.List))
|
||||||
|
|
||||||
@impl RDF.Serialization.Encoder
|
@impl RDF.Serialization.Encoder
|
||||||
@spec encode(RDF.Data.t(), Options.t() | Enum.t()) :: {:ok, String.t()} | {:error, any}
|
@spec encode(RDF.Data.t(), keyword) :: {:ok, String.t()} | {:error, any}
|
||||||
def encode(data, opts \\ []) do
|
def encode(data, opts \\ []) do
|
||||||
with {:ok, json_ld_object} <- from_rdf(data, opts),
|
with {:ok, json_ld_object} <- from_rdf(data, opts),
|
||||||
{:ok, json_ld_object} <- maybe_compact(json_ld_object, opts) do
|
{:ok, json_ld_object} <- maybe_compact(json_ld_object, opts) do
|
||||||
|
@ -62,7 +62,7 @@ defmodule JSON.LD.Encoder do
|
||||||
|
|
||||||
# TODO: unless we find a way to allow more optimized encode! versions, remove this since it's never used (see the respective warning)
|
# TODO: unless we find a way to allow more optimized encode! versions, remove this since it's never used (see the respective warning)
|
||||||
@impl RDF.Serialization.Encoder
|
@impl RDF.Serialization.Encoder
|
||||||
@spec encode!(RDF.Data.t(), Options.t() | Enum.t()) :: String.t()
|
@spec encode!(RDF.Data.t(), Options.convertible()) :: String.t()
|
||||||
@dialyzer {:nowarn_function, encode!: 1}
|
@dialyzer {:nowarn_function, encode!: 1}
|
||||||
def encode!(data, opts \\ []) do
|
def encode!(data, opts \\ []) do
|
||||||
case encode(data, opts) do
|
case encode(data, opts) do
|
||||||
|
|
|
@ -6,7 +6,7 @@ defmodule JSON.LD.Expansion do
|
||||||
alias JSON.LD.{Context, Options}
|
alias JSON.LD.{Context, Options}
|
||||||
alias JSON.LD.Context.TermDefinition
|
alias JSON.LD.Context.TermDefinition
|
||||||
|
|
||||||
@spec expand(map, Options.t() | Enum.t()) :: [map]
|
@spec expand(map | [map], Options.convertible()) :: [map]
|
||||||
def expand(input, options \\ %Options{}) do
|
def expand(input, options \\ %Options{}) do
|
||||||
options = Options.new(options)
|
options = Options.new(options)
|
||||||
active_context = Context.new(options)
|
active_context = Context.new(options)
|
||||||
|
|
|
@ -5,8 +5,7 @@ defmodule JSON.LD.Flattening do
|
||||||
|
|
||||||
alias JSON.LD.{NodeIdentifierMap, Options}
|
alias JSON.LD.{NodeIdentifierMap, Options}
|
||||||
|
|
||||||
@dialyzer {:nowarn_function, flatten: 3}
|
@spec flatten(map | [map], map | nil, Options.convertible()) :: [map]
|
||||||
@spec flatten(map | [map], map | nil, Options.t() | Enum.t()) :: [map]
|
|
||||||
def flatten(input, context \\ nil, options \\ %Options{}) do
|
def flatten(input, context \\ nil, options \\ %Options{}) do
|
||||||
options = Options.new(options)
|
options = Options.new(options)
|
||||||
expanded = JSON.LD.expand(input, options)
|
expanded = JSON.LD.expand(input, options)
|
||||||
|
|
|
@ -16,7 +16,7 @@ defmodule JSON.LD.Options do
|
||||||
processing_mode: String.t()
|
processing_mode: String.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
@type convertible :: t | Enum.t()
|
@type convertible :: t | keyword | Enum.t()
|
||||||
|
|
||||||
defstruct base: nil,
|
defstruct base: nil,
|
||||||
compact_arrays: true,
|
compact_arrays: true,
|
||||||
|
|
|
@ -57,9 +57,7 @@ defmodule JSON.LD do
|
||||||
|
|
||||||
Details at <http://json-ld.org/spec/latest/json-ld-api/#expansion-algorithm>
|
Details at <http://json-ld.org/spec/latest/json-ld-api/#expansion-algorithm>
|
||||||
"""
|
"""
|
||||||
@spec expand(map, Options.t() | Enum.t()) :: [map]
|
defdelegate expand(input, options \\ %Options{}), to: Expansion
|
||||||
defdelegate expand(input, options \\ %Options{}),
|
|
||||||
to: Expansion
|
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Compacts the given input according to the steps in the JSON-LD Compaction Algorithm.
|
Compacts the given input according to the steps in the JSON-LD Compaction Algorithm.
|
||||||
|
@ -74,9 +72,7 @@ defmodule JSON.LD do
|
||||||
|
|
||||||
Details at <https://www.w3.org/TR/json-ld-api/#compaction-algorithms>
|
Details at <https://www.w3.org/TR/json-ld-api/#compaction-algorithms>
|
||||||
"""
|
"""
|
||||||
@spec compact(map | [map], map | nil, Options.t() | Enum.t()) :: map
|
defdelegate compact(input, context, options \\ %Options{}), to: Compaction
|
||||||
defdelegate compact(input, context, options \\ %Options{}),
|
|
||||||
to: Compaction
|
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Flattens the given input according to the steps in the JSON-LD Flattening Algorithm.
|
Flattens the given input according to the steps in the JSON-LD Flattening Algorithm.
|
||||||
|
@ -90,9 +86,7 @@ defmodule JSON.LD do
|
||||||
|
|
||||||
Details at <https://www.w3.org/TR/json-ld-api/#flattening-algorithms>
|
Details at <https://www.w3.org/TR/json-ld-api/#flattening-algorithms>
|
||||||
"""
|
"""
|
||||||
@spec flatten(map | [map], map | nil, Options.t() | Enum.t()) :: [map]
|
defdelegate flatten(input, context \\ nil, options \\ %Options{}), to: Flattening
|
||||||
defdelegate flatten(input, context \\ nil, options \\ %Options{}),
|
|
||||||
to: Flattening
|
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Generator function for `JSON.LD.Context`s.
|
Generator function for `JSON.LD.Context`s.
|
||||||
|
@ -112,7 +106,5 @@ defmodule JSON.LD do
|
||||||
@doc """
|
@doc """
|
||||||
Generator function for JSON-LD node maps.
|
Generator function for JSON-LD node maps.
|
||||||
"""
|
"""
|
||||||
@spec node_map([map], pid | nil) :: map
|
defdelegate node_map(input, node_id_map \\ nil), to: Flattening
|
||||||
defdelegate node_map(input, node_id_map \\ nil),
|
|
||||||
to: Flattening
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue