Standardise blank lines in the formatter - #7523
Open
ewels wants to merge 1 commit into
Open
Conversation
Normalise the number of blank lines, PEP8/Ruff-style: - exactly 2 blank lines around top-level block definitions (process, workflow, function, params, output, record, enum, agent), and between a definition and any adjacent declaration; - simple declarations (includes, feature flags, legacy params) stay grouped, with runs collapsed to at most one blank line; - process and workflow sections stay separated by exactly one blank line (issue #150); - blank lines at the start of a block or section are removed; - a shebang is followed by exactly one blank line; - runs of blank lines anywhere else collapse to at most one. Config files get the same treatment, with config blocks set off by one blank line (config is denser than script definitions). Verbatim regions (`fmt: off` / `fmt: skip`) keep their original spacing. Top-level spacing is now driven by policy in the declaration loop rather than derived from the source position of each node; the within-line blank collapse stays a stateless re-derivation from the source. Assisted-by: Claude Opus 4.8 (Claude Code) Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The policy (PEP8/Ruff-style):
fmt: off/fmt: skip, from the PR below this one) keep their original spacing untouched.Notes:
formatter-fmt-directives(see Ability to skip formatting for specific sections of code language-server#75 ), which stacks on the wrapping and sort PRs below it. Review/merge those first; the diff here is only the blank-line change.Two decisions worth a look in review, both intentional and easy to change:
Mechanically, top-level spacing is now driven by policy in the declaration loop (
blankLinesBetween(prev, decl)) rather than derived from each node's source position; the within-line collapse stays a stateless re-derivation from the source, and blank lines at a block/section start are dropped via a smallatBlockStartflag set by each opener.Example
Before:
include { FOO } from './modules/foo.nf' process ALIGN { input: path reads script: 'echo' } workflow { ALIGN(reads) }After:
include { FOO } from './modules/foo.nf' process ALIGN { input: path reads script: 'echo' } workflow { ALIGN(reads) }The include block is separated from the process by 2 blank lines (a definition), the run of blanks before
script:collapses to the single blank that separates sections, and the 3 blank lines beforeworkflownormalise to 2.Assisted-by: Claude Opus 4.8 (Claude Code)