Skip to content

Else branch after conditional include breaks depending on subsequent code #239

@lczech

Description

@lczech

I think this is a regression of #115, or an extension of the issue reported there.

Minimal example, using snakefmt v0.10.2:

if condition:
    include: "my_rule.smk"
else:
    raise Exception("Condition not given")

if other_condition:
    rule other_rule:
        input:
            somefile

The error is:

snakefmt.exceptions.InvalidPython: Black error:
Cannot parse: 3:0: else:

Removing the second conditional part however solves this, despite that part not having anything to do with the condition that causes the problem.

My current workaround is to rewrite the else branch as

if not condition:
    raise Exception("Condition not given")

but since in my actual code I have a few elif befor that, this is quite cumbersome.

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