snakemake / snakefmt

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

Broken indentation after formatting #171

Closed jzhang-dev closed 1 year ago

jzhang-dev commented 1 year ago

I noticed the indentation in the run section of my rule was broken after formatting:

$ snakefmt --version
snakefmt, version 0.8.0
$ cat Snakefile 
rule test:
    input:
        gfa="mdbg.gfa",
    output:
        gfa="mdbg.no_seq.gfa",
    run:
        with open(input.gfa, "rt") as fi, open(output.gfa, "wt") as fo:
            for line in fi:
                if line.startswith("S"):
                    record_type, name, sequence, *__ = line.strip("\n").split(
                        "\t", maxsplit=3
                    )
                    new_line = (
                        "\t".join([record_type, name, "*", f"LN:i:{len(sequence)}"])
                    + "\n"
                                )
                else:
                    new_line = line
                fo.write(new_line)

Please note the line starting with new _line =:

$ snakefmt - < Snakefile 
rule test:
    input:
        gfa="mdbg.gfa",
    output:
        gfa="mdbg.no_seq.gfa",
    run:
        with open(input.gfa, "rt") as fi, open(output.gfa, "wt") as fo:
            for line in fi:
                if line.startswith("S"):
                    record_type, name, sequence, *__ = line.strip("\n").split(
                        "\t", maxsplit=3
                        )
                        new_line = (
                            "\t".join([record_type, name, "*", f"LN:i:{len(sequence)}"])
                        + "\n"
                    )
                else:
                    new_line = line
                fo.write(new_line)
[INFO] All done 🎉
mbhall88 commented 1 year ago

Sorry about this @jzhang-dev. We've got a few indentation-related problems currently, we'll try and get to the bottom of this soon