Skip to content

cell_alignment should accept Vector{<:Function} or Vector{F} where F<:Function; literal vectors of anonymous functions throw TypeError #271

@abcdvvvv

Description

@abcdvvvv

Description
cell_alignment currently requires Vector{Function}. Literal vectors of anonymous functions have a concrete element type (e.g. Vector{var"#1#2"}) and are not subtypes of Vector{Function} due to invariance, which leads to a TypeError.

cell_alignment::Union{Nothing, Vector{Pair{NTuple{2, Int}, Symbol}}, Vector{Function}} = nothing,

Minimal repro

using PrettyTables
pretty_table(rand(3, 3);
    cell_alignment = [(_, i, _) -> (:r, :c, :l)[i]]
)

Actual

ERROR: TypeError: in keyword argument cell_alignment,
expected Union{Nothing, Vector{Function}, Vector{Pair{Tuple{Int64,Int64},Symbol}}},
got a value of type Vector{var"#1#2"}

Env

  • Julia: 1.10.10 (Windows)
  • PrettyTables: v3.0.8
  • Backend: :text

I should have submitted this issue earlier so that you could incorporate it into 3.0.9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions