Skip to content

snakemake --lint mistakes regex for path #3001

@cmeesters

Description

@cmeesters

Hi,

Snakemake version
8.16.0

Describe the bug

with this submodule in a workflow

import os
from pathlib import Path
import sys
from itertools import product

import pandas as pd
from snakemake.remote import FTP
from snakemake.utils import validate
from snakemake.exceptions import WorkflowError

validate(config, schema="../schemas/config.schema.yaml")

samples = (
    pd.read_csv(
        os.path.join(
            os.path.realpath(os.path.dirname(workflow.configfiles[0])),
            config["samples"],
        ),
        sep=r"\s+",
        dtype={"sample": str, "condition": str, "condition2": str, "batch_effect": str},
        header=0,
        comment="#",
    )
    .set_index("sample", drop=False)
    .sort_index()
)
...

Logs

I get this in the CI logs:

Lints for snakefile /github/workspace/workflow/rules/commons.smk:
    * Path composition with '+' in line 19:
      This becomes quickly unreadable. Usually, it is better to endure some
      redundancy against having a more readable workflow. Hence, just repeat
      common prefixes. If path composition is unavoidable, use pathlib or
      (python >= 3.6) string formatting with f"...".
      Also see:

Additional context

On the command line with snakefmt version 0.10.2 and black (internally used, version 24.4.2), I get no error.

Apparently, sep=r"\s+" is considered path concatenation, which it isn't.

We could use \t instead for a while, but this is semantically not identical.

Cheers,
Christian

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