From 4ff24ee5efeefaf5b75bef74afb5c5eb2efac366 Mon Sep 17 00:00:00 2001 From: MichaelHatherly Date: Thu, 17 Oct 2024 08:25:21 +0100 Subject: [PATCH] Pin `JuliaFormatter` to `v2` and fix new formatting failures --- .ci/Project.toml | 3 +++ src/QuartoNotebookWorker/src/render.jl | 8 ++++---- src/precompile.jl | 2 +- src/server.jl | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.ci/Project.toml b/.ci/Project.toml index f3aab8b..18a15b4 100644 --- a/.ci/Project.toml +++ b/.ci/Project.toml @@ -1,2 +1,5 @@ [deps] JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899" + +[compat] +JuliaFormatter = "2" diff --git a/src/QuartoNotebookWorker/src/render.jl b/src/QuartoNotebookWorker/src/render.jl index 0081614..d217312 100644 --- a/src/QuartoNotebookWorker/src/render.jl +++ b/src/QuartoNotebookWorker/src/render.jl @@ -57,7 +57,7 @@ function _render_thunk( return ((; code = "", # an expanded cell that errored can't have returned code cell_options = Dict{String,Any}(), # or options - results = Dict{String,@NamedTuple{error::Bool, data::Vector{UInt8}}}(), + results = Dict{String,@NamedTuple{error::Bool,data::Vector{UInt8}}}(), display_results, output = captured.output, error = string(typeof(error)), @@ -294,7 +294,7 @@ function clean_bt_str(is_error::Bool, bt, err, prefix = "", mimetype = false) if mimetype non_worker = findfirst(x -> contains(String(x.file), @__FILE__), bt) - bt = bt[1:max(something(non_worker, length(bt)) - 3, 0)] + bt = bt[1:max(something(non_worker, length(bt))-3, 0)] end buf = IOBuffer() @@ -329,7 +329,7 @@ function render_mimetypes(value, cell_options; inline::Bool = false) options = NotebookState.OPTIONS[] to_format = rget(options, ("format", "pandoc", "to"), nothing) - result = Dict{String,@NamedTuple{error::Bool, data::Vector{UInt8}}}() + result = Dict{String,@NamedTuple{error::Bool,data::Vector{UInt8}}}() # Some output formats that we want to write to need different # handling of valid MIME types. Currently `docx` and `typst`. When # we detect that the `to` format is one of these then we select a @@ -417,7 +417,7 @@ function render_mimetypes(value, cell_options; inline::Bool = false) return result end render_mimetypes(value::Nothing, cell_options; inline::Bool = false) = - Dict{String,@NamedTuple{error::Bool, data::Vector{UInt8}}}() + Dict{String,@NamedTuple{error::Bool,data::Vector{UInt8}}}() # Our custom MIME types need special handling. They get rendered to diff --git a/src/precompile.jl b/src/precompile.jl index 4178f37..01cd4d1 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -1,7 +1,7 @@ PrecompileTools.@setup_workload begin notebook = joinpath(@__DIR__, "..", "test", "examples", "cell_types.qmd") script = joinpath(@__DIR__, "..", "test", "examples", "cell_types.jl") - results = Dict{String,@NamedTuple{error::Bool, data::Vector{UInt8}}}() + results = Dict{String,@NamedTuple{error::Bool,data::Vector{UInt8}}}() PrecompileTools.@compile_workload begin raw_text_chunks(notebook) raw_text_chunks(script) diff --git a/src/server.jl b/src/server.jl index f1abab6..20e53fd 100644 --- a/src/server.jl +++ b/src/server.jl @@ -1017,7 +1017,7 @@ values. We do here rather than in the worker because we don't want to have to define additional functions in the worker and import `Base64` there. The worker just has to provide bytes. """ -function process_results(dict::Dict{String,@NamedTuple{error::Bool, data::Vector{UInt8}}}) +function process_results(dict::Dict{String,@NamedTuple{error::Bool,data::Vector{UInt8}}}) funcs = Dict( "application/json" => json_reader, "application/pdf" => Base64.base64encode,