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

Removal of whitespace in f-string when used with python 3.12 (not with python 3.11) #227

Closed
corneliusroemer opened this issue Apr 30, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@corneliusroemer
Copy link

corneliusroemer commented Apr 30, 2024

When running snakefmt through pre-commit I noticed an interesting edit.

In this rule:

rule subsample:
    input:
        metadata=build_dir + "/{build_name}/good_metadata.tsv",
    params:
        exclude=lambda w: (
            f"--exclude-where {' '.join([f'lineage={l}' for l in config['subsample'][w.sample]['exclude_lineages']])}"
            if "exclude_lineages" in config["subsample"][w.sample]
            else ""
        ),

in the following line:

from:

            f"--exclude-where {' '.join([f'lineage={l}' for l in config['subsample'][w.sample]['exclude_lineages']])}" 
                                                       ^ this space

to:

            f"--exclude-where {' '.join([f'lineage={l}'for l in config['subsample'][w.sample]['exclude_lineages']])}"
                                                       ^ is removed by v0.10.1 with python 3.12 only

Note: the space after ' in ' for l in config was removed.

I'm pretty sure pre-commit uses python3.12 on my system by default. I managed to work around this by telling pre-commit to use python3.11 (which is what I use in VScode's snakefmt).

This is another python3.12-only bug/change, similar to: #207 and #220

Workaround for all python3.12-only issues when using pre-commit:

  - repo: https://github.com/snakemake/snakefmt
    rev: v0.10.1
    hooks:
      - id: snakefmt
        language_version: python3.11  # <--- Add this line
corneliusroemer added a commit to nextstrain/mpox that referenced this issue Apr 30, 2024
- Ignore SC2027 in shellcheck (within actionlint)
- Use python3.11 for snakefmt to workaround snakemake/snakefmt#227
@mbhall88
Copy link
Member

mbhall88 commented May 2, 2024

Yeah, this is very tightly linked to #220. Hopefully @bricoletc or I can get around to fixing this soon. I tried recently but couldn't quite get it sorted and then had to go back to other projects.

Feel free to tackle it also @corneliusroemer if you feel up to it

@mbhall88 mbhall88 added the bug Something isn't working label May 2, 2024
bricoletc added a commit to bricoletc/snakefmt that referenced this issue May 6, 2024
bricoletc added a commit to bricoletc/snakefmt that referenced this issue May 7, 2024
mbhall88 pushed a commit that referenced this issue May 8, 2024
* fix: f-string spacing [closes #220 and #227]

* Remove unnecessary entries in f-string formatter
@mbhall88
Copy link
Member

mbhall88 commented May 8, 2024

this should be fixed in v0.10.2

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

No branches or pull requests

2 participants