snakemake / snakefmt

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

Ternary operator formatting reduces readability #150

Closed corneliusroemer closed 2 years ago

corneliusroemer commented 2 years ago

Here's an example where snakefmt seems to make things less readable:

Before:

rule abc:
    input:
        mutation_context = rules.mutation_context.output.node_data,
        recency = lambda w: rules.recency.output.node_data if config.get('recency', False) else [],
        colors = config["colors"],

After:

rule abc:
    input:
        mutation_context=rules.mutation_context.output.node_data,
        recency=lambda w: rules.recency.output.node_data
        if config.get("recency", False)
        else [],
        colors=config["colors"],

Would it be possible for ternary operators to be formatted better? I don't have a suggestion at this point, just that the way it's formatted makes it quite unreadable unfortunately.

mbhall88 commented 2 years ago

Duplicate of #124. Closing in favour of the original issue. Thank you for reporting, we'll try and get to this soon. Sorry about the delay.

The way this should be formatted is

rule abc:
    input:
        mutation_context=rules.mutation_context.output.node_data,
        recency=lambda w: rules.recency.output.node_data
            if config.get("recency", False)
            else [],
        colors=config["colors"],
corneliusroemer commented 2 years ago

Thanks! Sorry I missed the duplicate, good to hear this is considered a bug with a nice solution :)