Skip to content

Writing a docstring within a rule leads to SyntaxtError when using use rule ... as ... with: statement. #3677

@tdayris

Description

@tdayris

Snakemake version: 9.8.0

Describe the bug

When using use rule ... as ... with: statement in Snakemake, then writing a docstring leads to a syntax error.

Minimal example and Logs

The following works:

rule a:
    """Docstring of rule A."""
    output:
        "a.yaml",
    threads: 1
    log:
        "logs/a.log",
    params:
        foo="bar",
    shell:
        "echo 'foo: {params.foo}' > {output}"

use rule a as b with:
    output:
        "b.yaml",
    threads: 1
    log:
        "logs/b.log",
    params:
        foo="barbar",

but leads to:

$ snakemake -j1 --list
a (Docstring of rule A.)
b (Docstring of rule A.)

The following does not work:

rule a:
    """Docstring of rule A."""
    output:
        "a.yaml",
    threads: 1
    log:
        "logs/a.log",
    params:
        foo="bar",
    shell:
        "echo 'foo: {params.foo}' > {output}"

use rule a as b with:
    """Docstring of rule B."""
    output:
        "b.yaml",
    threads: 1
    log:
        "logs/b.log",
    params:
        foo="barbar",

Leading to:

$ snakemake -j1 --list
SyntaxError in file "/path/to/Snakefile", line 12:
Expecting a keyword or comment inside a 'use rule ... with:' statement.:
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions