[Python] How to prevent Snakemake from stripping lines without variables in multiline...

Discussão em 'Python' iniciado por Stack, Julho 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm encountering an issue where Snakemake seems to remove lines from multiline f-strings that don't contain any variables, while regular Python preserves them.

    Here's my test case:

    # Snakefile
    foo = "bar"

    fstring = f"""
    This line should be kept
    foo: {foo}
    """

    print(fstring)


    When I run this with Python directly, I get the expected output:

    $ python Snakefile
    This line should be kept
    foo: bar


    But when I run it with Snakemake:

    $ snakemake -n
    foo: bar

    Building DAG of jobs...
    Nothing to be done (all requested files are present and up to date).


    Notice that the line "This line should be kept" is missing in the Snakemake output.

    Questions:

    1. Why does Snakemake behave differently with multiline f-strings?
    2. Is there a way to make Snakemake preserve all lines in the f-string, including those without variables?
    3. Is this a known behavior or potentially a bug?

    I'm using Snakemake 9.8.0. Any insights or workarounds would be appreciated.

    Continue reading...

Compartilhe esta Página