Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: snakefmt erroneously removes double braces, {{x}} -> {x} #207

Closed
corneliusroemer opened this issue Nov 14, 2023 · 7 comments · Fixed by #213
Closed

Bug: snakefmt erroneously removes double braces, {{x}} -> {x} #207

corneliusroemer opened this issue Nov 14, 2023 · 7 comments · Fixed by #213
Labels
bug Something isn't working

Comments

@corneliusroemer
Copy link

Snakefmt makes illegal syntax changes:

rule align:
    input:
        sequences="results/{build_name}/filtered.fasta",
    params:
        translation_template=lambda w: f"results/{w.build_name}/translations/{{cds}}.fasta",

is formatted to

rule align:
    input:
        sequences="results/{build_name}/filtered.fasta",
    params:
        translation_template=lambda w: f"results/{w.build_name}/translations/{cds}.fasta",

I.e. the double curly braces around {{cds}} are replaced by single curly braces {cds}.

This might be ok to do in Python, but it isn't ok in Snakemake, as I need literal braces here, no replacement at all is wanted.

image

This happens with the snakefmt in precommit: rev: v0.8.4

@corneliusroemer
Copy link
Author

I updated the version to 0.8.5 in precommit but I still get the error. Weirdly, when I run snakefmt. --check from command line with version 0.8.5 I don't get any error.

@mbhall88 mbhall88 added the bug Something isn't working label Nov 15, 2023
@mbhall88
Copy link
Member

Ooof that's not good. Sorry it's been hard to find time to work on this tool in recent months.
I will try and look into these bugs in the coming month or two, but feel free to have a look too. We'd be very happy to have the community involved

@corneliusroemer
Copy link
Author

No worries at all, I understand it's hard to maintain snakefmt.

This bug is really weird, the fact it's only affecting pre-commit could mean something is wrong in that part, or maybe not even within snakefmt. I'll see if I can investigate further, this seems hard to repro for others, I think.

corneliusroemer added a commit to nextstrain/mpox that referenced this issue Nov 15, 2023
@mbhall88
Copy link
Member

@corneliusroemer I can't replicate this error in snakefmt 0.8.5. Can you confirm your precommit is definitely using 0.8.5?

@corneliusroemer
Copy link
Author

I'm trying to set up a minimal reproducible example but getting some weird pre-commit installed errors like:

 note: This error originates from a subprocess, and is likely not a problem with pip.
      ERROR: Failed building wheel for multidict
    ERROR: Could not build wheels for multidict, which is required to install pyproject.toml-based projects

Will have a look later and try again when I have more time.

@y9c
Copy link

y9c commented Jan 4, 2024

Might relative to Python version? Can reproduce under Python 3.12

@corneliusroemer
Copy link
Author

Great catch @y9c!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants