Skip to content

Commit fa59ebc

Browse files
davidanthoffgithub-actions[bot]
authored andcommitted
Format files using DocumentFormat
1 parent 70dabff commit fa59ebc

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

src/core.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const RPCErrorStrings = Base.IdDict(
8787
METHOD_NOT_FOUND => "MethodNotFound",
8888
INVALID_PARAMS => "InvalidParams",
8989
INTERNAL_ERROR => "InternalError",
90-
[ i => "ServerError" for i in SERVER_ERROR_START:SERVER_ERROR_END]...,
90+
[i => "ServerError" for i in SERVER_ERROR_START:SERVER_ERROR_END]...,
9191
-32002 => "ServerNotInitialized",
9292
-32001 => "UnknownErrorCode",
9393
)
@@ -105,7 +105,7 @@ function Base.showerror(io::IO, ex::JSONRPCError)
105105
end
106106
end
107107

108-
mutable struct JSONRPCEndpoint{IOIn <: IO,IOOut <: IO}
108+
mutable struct JSONRPCEndpoint{IOIn<:IO,IOOut<:IO}
109109
pipe_in::IOIn
110110
pipe_out::IOOut
111111

@@ -122,7 +122,7 @@ mutable struct JSONRPCEndpoint{IOIn <: IO,IOOut <: IO}
122122
write_task::Union{Nothing,Task}
123123
end
124124

125-
JSONRPCEndpoint(pipe_in, pipe_out, err_handler = nothing) =
125+
JSONRPCEndpoint(pipe_in, pipe_out, err_handler=nothing) =
126126
JSONRPCEndpoint(pipe_in, pipe_out, Channel{Any}(Inf), Channel{Any}(Inf), Dict{String,Channel{Any}}(), err_handler, :idle, nothing, nothing)
127127

128128
function write_transport_layer(stream, response)
@@ -213,7 +213,7 @@ function Base.run(x::JSONRPCEndpoint)
213213
put!(channel_for_response, message_dict)
214214
end
215215
end
216-
216+
217217
close(x.in_msg_queue)
218218

219219
for i in values(x.outstanding_requests)
@@ -280,7 +280,7 @@ function get_next_message(endpoint::JSONRPCEndpoint)
280280
return msg
281281
end
282282

283-
function Base.iterate(endpoint::JSONRPCEndpoint, state = nothing)
283+
function Base.iterate(endpoint::JSONRPCEndpoint, state=nothing)
284284
check_dead_endpoint!(endpoint)
285285

286286
try

src/interface_def.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ end
2323

2424
function field_allows_missing(field::Expr)
2525
field.head == :(::) && field.args[2] isa Expr &&
26-
field.args[2].head == :curly && field.args[2].args[1] == :Union &&
27-
any(i -> i == :Missing, field.args[2].args)
26+
field.args[2].head == :curly && field.args[2].args[1] == :Union &&
27+
any(i -> i == :Missing, field.args[2].args)
2828
end
2929

3030
function field_type(field::Expr, typename::String)
@@ -55,9 +55,9 @@ macro dict_readable(arg)
5555
$((arg))
5656

5757
$(count_real_fields > 0 ? :(
58-
function $tname(; $((get_kwsignature_for_field(field) for field in arg.args[3].args if !(field isa LineNumberNode))...))
59-
$tname($((field.args[1] for field in arg.args[3].args if !(field isa LineNumberNode))...))
60-
end
58+
function $tname(; $((get_kwsignature_for_field(field) for field in arg.args[3].args if !(field isa LineNumberNode))...))
59+
$tname($((field.args[1] for field in arg.args[3].args if !(field isa LineNumberNode))...))
60+
end
6161
) : nothing)
6262

6363
function $tname(dict::Dict)

src/typed.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929
# so that we get an error in the typecast at the end of `send`
3030
# if that is not the case.
3131
typed_res(res, TR::Type{Nothing}) = res
32-
typed_res(res, TR::Type{<:T}) where {T <: AbstractArray{Any}} = T(res)
32+
typed_res(res, TR::Type{<:T}) where {T<:AbstractArray{Any}} = T(res)
3333
typed_res(res, TR::Type{<:AbstractArray{T}}) where T = T.(res)
3434
typed_res(res, TR::Type) = TR(res)
3535

@@ -62,7 +62,7 @@ function dispatch_msg(x::JSONRPCEndpoint, dispatcher::MsgDispatcher, msg)
6262
handler = get(dispatcher._handlers, method_name, nothing)
6363
if handler !== nothing
6464
param_type = get_param_type(handler.message_type)
65-
params = param_type === Nothing ? nothing : param_type <: NamedTuple ? convert(param_type,(;(Symbol(i[1])=>i[2] for i in msg["params"])...)) : param_type(msg["params"])
65+
params = param_type === Nothing ? nothing : param_type <: NamedTuple ? convert(param_type, (; (Symbol(i[1]) => i[2] for i in msg["params"])...)) : param_type(msg["params"])
6666

6767
res = handler.func(x, params)
6868

@@ -73,7 +73,7 @@ function dispatch_msg(x::JSONRPCEndpoint, dispatcher::MsgDispatcher, msg)
7373
send_success_response(x, msg, res)
7474
else
7575
error_msg = "The handler for the '$method_name' request returned a value of type $(typeof(res)), which is not a valid return type according to the request definition."
76-
send_error_response(x, msg, -32603, error_msg, nothing)
76+
send_error_response(x, msg, -32603, error_msg, nothing)
7777
error(error_msg)
7878
end
7979
end
@@ -97,9 +97,9 @@ macro message_dispatcher(name, body)
9797
:(
9898
if method_name == $(esc(i.args[2])).method
9999
param_type = get_param_type($(esc(i.args[2])))
100-
params = param_type === Nothing ? nothing : param_type <: NamedTuple ? convert(param_type,(;(Symbol(i[1])=>i[2] for i in msg["params"])...)) : param_type(msg["params"])
100+
params = param_type === Nothing ? nothing : param_type <: NamedTuple ? convert(param_type, (; (Symbol(i[1]) => i[2] for i in msg["params"])...)) : param_type(msg["params"])
101101

102-
if context===nothing
102+
if context === nothing
103103
res = $(esc(i.args[3]))(x, params)
104104
else
105105
res = $(esc(i.args[3]))(x, params, context)
@@ -112,14 +112,14 @@ macro message_dispatcher(name, body)
112112
send_success_response(x, msg, res)
113113
else
114114
error_msg = "The handler for the '$method_name' request returned a value of type $(typeof(res)), which is not a valid return type according to the request definition."
115-
send_error_response(x, msg, -32603, error_msg, nothing)
115+
send_error_response(x, msg, -32603, error_msg, nothing)
116116
error(error_msg)
117117
end
118118
end
119119

120120
return
121121
end
122-
) for i in filter(i->i isa Expr, body.args)
122+
) for i in filter(i -> i isa Expr, body.args)
123123
)...
124124
)
125125

test/shared_test_code.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
fieldB::Vector{Int}
1616
end
1717

18-
Base.:(==)(a::Foo2,b::Foo2) = a.fieldA == b.fieldA && a.fieldB == b.fieldB
18+
Base.:(==)(a::Foo2, b::Foo2) = a.fieldA == b.fieldA && a.fieldB == b.fieldB
1919

2020
end

test/test_interface_def.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
@testitem "Interface Definition" setup=[TestStructs] begin
1+
@testitem "Interface Definition" setup = [TestStructs] begin
22
using JSON
33
using .TestStructs: Foo, Foo2
4-
4+
55
@test_throws ErrorException Foo()
66

77
a = Foo(fieldA=1, fieldB="A")
@@ -21,14 +21,14 @@
2121
@test Foo(JSON.parse(JSON.json(a))) == a
2222
@test Foo(JSON.parse(JSON.json(b))) == b
2323

24-
c = Foo2(fieldA=nothing, fieldB=[1,2])
24+
c = Foo2(fieldA=nothing, fieldB=[1, 2])
2525

2626
@test c.fieldA === nothing
27-
@test c.fieldB == [1,2]
27+
@test c.fieldB == [1, 2]
2828
@test Foo2(JSON.parse(JSON.json(c))) == c
2929

30-
d = Foo2(fieldA=3, fieldB=[1,2])
30+
d = Foo2(fieldA=3, fieldB=[1, 2])
3131
@test d.fieldA === 3
32-
@test d.fieldB == [1,2]
32+
@test d.fieldB == [1, 2]
3333
@test Foo2(JSON.parse(JSON.json(d))) == d
3434
end

test/test_typed.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testitem "Dynamic message dispatcher" setup=[TestStructs] begin
1+
@testitem "Dynamic message dispatcher" setup = [TestStructs] begin
22
using Sockets
33
using .TestStructs: Foo, Foo2
44

@@ -70,7 +70,7 @@
7070
global conn = JSONRPC.JSONRPCEndpoint(sock, sock)
7171
global msg_dispatcher = JSONRPC.MsgDispatcher()
7272

73-
msg_dispatcher[request2_type] = (conn, params)->34 # The request type requires a `String` return, so this tests whether we get an error.
73+
msg_dispatcher[request2_type] = (conn, params) -> 34 # The request type requires a `String` return, so this tests whether we get an error.
7474

7575
run(conn)
7676

@@ -100,19 +100,19 @@ end
100100

101101
@testitem "check response type" begin
102102
using JSONRPC: typed_res
103-
103+
104104
@test typed_res(nothing, Nothing) isa Nothing
105-
@test typed_res([1,"2",3], Vector{Any}) isa Vector{Any}
106-
@test typed_res([1,2,3], Vector{Int}) isa Vector{Int}
107-
@test typed_res([1,2,3], Vector{Float64}) isa Vector{Float64}
108-
@test typed_res(['f','o','o'], String) isa String
105+
@test typed_res([1, "2", 3], Vector{Any}) isa Vector{Any}
106+
@test typed_res([1, 2, 3], Vector{Int}) isa Vector{Int}
107+
@test typed_res([1, 2, 3], Vector{Float64}) isa Vector{Float64}
108+
@test typed_res(['f', 'o', 'o'], String) isa String
109109
@test typed_res("foo", String) isa String
110110
end
111111

112-
@testitem "Static message dispatcher" setup=[TestStructs] begin
112+
@testitem "Static message dispatcher" setup = [TestStructs] begin
113113
using Sockets
114114
using .TestStructs: Foo, Foo2
115-
115+
116116
global_socket_name1 = JSONRPC.generate_pipe_name()
117117

118118
request1_type = JSONRPC.RequestType("request1", Foo, String)

0 commit comments

Comments
 (0)