snakemake / snakefmt

The uncompromising Snakemake code formatter
MIT License
151 stars 29 forks source link

Long parenthesis within rule settings breaks code #240

Open lczech opened 3 months ago

lczech commented 3 months ago

This is with snakefmt v0.10.2.

Minimal example:

rule call_variants:
    input:
        some_file
    threads:
        max(
            1,
            int(config["params"]["call_variants"]["threads"]) -
            int(config["params"]["call_variants"]["compress-threads"])
        )

gets reformatted to

rule call_variants:
    input:
        some_file,
    threads: max(
    1,
    int(config["params"]["call_variants"]["threads"])
    - int(config["params"]["call_variants"]["compress-threads"]),
)

This cannot be parsed again, as calling snakefmt again on this yields:

snakefmt.exceptions.InvalidParameterSyntax: 5max(

The issue is only appearing due to the long lines. Removing this, computing the needed value beforehand, and instead just having a shorter statement there, works.

mbhall88 commented 3 months ago

I think this is the same underlying issue for #208

We'll try and investigate this soon (sorry, writing grants at the moment)