From e622ef4f96090dee15adcd91eb5a2645e45cfc04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Fri, 3 Feb 2023 18:30:41 +0100 Subject: [PATCH] Fix dialyzer warnings (#1691) --- lib/livebook/application.ex | 2 ++ lib/livebook/config.ex | 2 +- lib/livebook/notebook/cell/code.ex | 2 +- lib/livebook/notebook/cell/markdown.ex | 2 +- lib/livebook/notebook/cell/smart.ex | 6 +++--- lib/livebook/settings/env_var.ex | 4 ++-- mix.exs | 2 ++ test/support/test_modules/bad_inspect.ex | 2 ++ 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/livebook/application.ex b/lib/livebook/application.ex index 87bacbd05..54a77cf12 100644 --- a/lib/livebook/application.ex +++ b/lib/livebook/application.ex @@ -254,6 +254,8 @@ defmodule Livebook.Application do end end + @dialyzer {:no_return, iframe_port_in_use: 1} + defp iframe_port_in_use(port) do Livebook.Config.abort!( "Failed to start Livebook iframe server because port #{port} is already in use" diff --git a/lib/livebook/config.ex b/lib/livebook/config.ex index 5d2984510..beab92514 100644 --- a/lib/livebook/config.ex +++ b/lib/livebook/config.ex @@ -132,7 +132,7 @@ defmodule Livebook.Config do @doc """ Returns an mfa if there's a way to shut down the system. """ - @spec shutdown_callback() :: mfa() | nil + @spec shutdown_callback() :: {module(), atom(), list()} | nil def shutdown_callback() do Application.fetch_env!(:livebook, :shutdown_callback) end diff --git a/lib/livebook/notebook/cell/code.ex b/lib/livebook/notebook/cell/code.ex index 2efbd352b..238841158 100644 --- a/lib/livebook/notebook/cell/code.ex +++ b/lib/livebook/notebook/cell/code.ex @@ -13,7 +13,7 @@ defmodule Livebook.Notebook.Cell.Code do @type t :: %__MODULE__{ id: Cell.id(), - source: String.t(), + source: String.t() | :__pruned__, outputs: list(Cell.indexed_output()), disable_formatting: boolean(), reevaluate_automatically: boolean() diff --git a/lib/livebook/notebook/cell/markdown.ex b/lib/livebook/notebook/cell/markdown.ex index baf25754e..9bac3d765 100644 --- a/lib/livebook/notebook/cell/markdown.ex +++ b/lib/livebook/notebook/cell/markdown.ex @@ -13,7 +13,7 @@ defmodule Livebook.Notebook.Cell.Markdown do @type t :: %__MODULE__{ id: Cell.id(), - source: String.t() + source: String.t() | :__pruned__ } @doc """ diff --git a/lib/livebook/notebook/cell/smart.ex b/lib/livebook/notebook/cell/smart.ex index 87d398b1b..b5156e2be 100644 --- a/lib/livebook/notebook/cell/smart.ex +++ b/lib/livebook/notebook/cell/smart.ex @@ -10,11 +10,11 @@ defmodule Livebook.Notebook.Cell.Smart do @type t :: %__MODULE__{ id: Cell.id(), - source: String.t(), + source: String.t() | :__pruned__, chunks: Livebook.Runtime.chunks() | nil, outputs: list(Cell.indexed_output()), - kind: String.t(), - attrs: attrs(), + kind: String.t() | nil, + attrs: attrs() | :__pruned__, js_view: Livebook.Runtime.js_view() | nil, editor: Livebook.Runtime.editor() | nil } diff --git a/lib/livebook/settings/env_var.ex b/lib/livebook/settings/env_var.ex index 9f6c8ee3d..321995c7f 100644 --- a/lib/livebook/settings/env_var.ex +++ b/lib/livebook/settings/env_var.ex @@ -4,8 +4,8 @@ defmodule Livebook.Settings.EnvVar do import Ecto.Changeset @type t :: %__MODULE__{ - name: String.t(), - value: String.t() + name: String.t() | nil, + value: String.t() | nil } @primary_key {:name, :string, autogenerate: false} diff --git a/mix.exs b/mix.exs index d50068175..d46b0f4b2 100644 --- a/mix.exs +++ b/mix.exs @@ -153,6 +153,8 @@ defmodule Livebook.MixProject do release end + @compile {:no_warn_undefined, Standalone} + defp standalone_erlang_elixir(release) do Code.require_file("rel/app/standalone.exs") diff --git a/test/support/test_modules/bad_inspect.ex b/test/support/test_modules/bad_inspect.ex index df89cd0e9..ddba8567b 100644 --- a/test/support/test_modules/bad_inspect.ex +++ b/test/support/test_modules/bad_inspect.ex @@ -2,6 +2,8 @@ defmodule Livebook.TestModules.BadInspect do defstruct [] defimpl Inspect do + @dialyzer {:nowarn_function, inspect: 2} + def inspect(%Livebook.TestModules.BadInspect{}, _opts) do :bad_return end