Skip to content

Formatting output changed in minor version increment #1013

Description

@MilesCranmer

In 2.5.0, the formatter changed how it wraps a short-form (assignment) method definition whose full line exceeds the margin. 2.4.0 wraps the right-hand-side call arguments; 2.5.0 wraps the left-hand-side signature arguments instead. The two outputs are mutually idempotent, so a codebase formatted with one version is reported as unformatted by the other.

This surfaced as a CI break for us: our format check pins JuliaFormatter@2 (floating), so when 2.5.0 was published, format(".") started reporting files across the repo as needing changes even though nothing in the repo had changed. Pinning back to 2.4.0 resolves it.

Minimal reproducer:

.JuliaFormatter.toml

style = "blue"
pipe_to_function_call = false

x.jl

check_constraints(ex::Union{AbstractExpression,AbstractExpressionNode}, options::AbstractOptions)::Bool = check_constraints(ex, options, options.maxsize)

Run using JuliaFormatter; format(".").

2.4.0 (wraps the call on the RHS):

check_constraints(ex::Union{AbstractExpression,AbstractExpressionNode}, options::AbstractOptions)::Bool = check_constraints(
    ex, options, options.maxsize
)

2.5.0-2.5.2 (wraps the signature on the LHS):

check_constraints(
    ex::Union{AbstractExpression,AbstractExpressionNode}, options::AbstractOptions
)::Bool = check_constraints(ex, options, options.maxsize)

Julia 1.12.6, blue style. 2.4.0 is unaffected; the change first appears in 2.5.0. I tested it on 2.5.2 and it is still there.

Is this an intentional style change? If so, it would help to call it out in the changelog (or have it be opt-in via the config before a v3 is released), since it silently invalidates previously-formatted code whose CI floats on @2.

Many thanks,
Miles

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Priority 2 — see contributing docs

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions