mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2026-02-15 17:16:57 +00:00
Elixir 1.19: Fix typing violation on struct updates in Web.ApiSpec.Rend*
warning: a struct for OpenApiSpex.Cast.Error is expected on struct update:
%OpenApiSpex.Cast.Error{err | name: err.value}
but got type:
dynamic(%{..., name: nil, reason: :invalid_enum})
where "err" was given the type:
# type: dynamic(%{..., name: nil, reason: :invalid_enum})
# from: lib/pleroma/web/api_spec/render_error.ex:20:45
%{name: nil, reason: :invalid_enum} = err
when defining the variable "err", you must also pattern match on "%OpenApiSpex.Cast.Error{}".
hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:
user = some_function()
%User{user | name: "John Doe"}
it is enough to write:
%User{} = user = some_function()
%{user | name: "John Doe"}
typing violation found at:
│
21 │ %OpenApiSpex.Cast.Error{err | name: err.value}
│ ~
│
└─ lib/pleroma/web/api_spec/render_error.ex:21:11: Pleroma.Web.ApiSpec.RenderError.call/2
This commit is contained in:
parent
7d2518a9ae
commit
a84e091c4e
1 changed files with 2 additions and 2 deletions
|
|
@ -17,10 +17,10 @@ defmodule Pleroma.Web.ApiSpec.RenderError do
|
||||||
def call(conn, errors) do
|
def call(conn, errors) do
|
||||||
errors =
|
errors =
|
||||||
Enum.map(errors, fn
|
Enum.map(errors, fn
|
||||||
%{name: nil, reason: :invalid_enum} = err ->
|
%OpenApiSpex.Cast.Error{name: nil, reason: :invalid_enum} = err ->
|
||||||
%OpenApiSpex.Cast.Error{err | name: err.value}
|
%OpenApiSpex.Cast.Error{err | name: err.value}
|
||||||
|
|
||||||
%{name: nil} = err ->
|
%OpenApiSpex.Cast.Error{name: nil} = err ->
|
||||||
%OpenApiSpex.Cast.Error{err | name: List.last(err.path)}
|
%OpenApiSpex.Cast.Error{err | name: List.last(err.path)}
|
||||||
|
|
||||||
err ->
|
err ->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue