-
Notifications
You must be signed in to change notification settings - Fork 545
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
nested for loop in f-string #2881
Comments
Snakemake states an error in your Snakefile. Please provide a minimal example to produce your error using the current version of Snakemake. |
Yes... This is indeed a bug that caused by f-string. In brief, python will split each 'word' in fstring such as This bug will be fixed in the future, but it is also better to use f-string in a more gentle way :) |
<!--Add a description of your PR here--> This is another (and hopefully the last) fix for f-string change in python3.12. Now everthing inner f-string are ignored, and only care about where f-string start and end, and read it from snakefile as-is. will fix #2881 and fix #2657 related PR: #2864, #2649 ### QC <!-- Make sure that you can tick the boxes below. --> * [x] The PR contains a test case for the changes or the changes are already covered by an existing test case. * [x] The documentation (`docs/`) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).
Snakemake version
Bug in latest versions. Tested versions 8.7.0 and 8.11.3.
Works in version 7.18.2
Describe the bug
I often use nested 'for' loops to create a list (outside of a rule). This works fine, but if the loop is placed WITHIN an f-string it does not work with the latest versions of snakemake. Before version 8 it was working.
Logs
$ snakemake -j1
SyntaxError in file Snakefile, line 6:
invalid syntax. Perhaps you forgot a comma? (Snakefile, line 6)
Minimal example
works for both versions
a = [(x, y) for x in [1,2,3] for y in [3,1,4]]
print(f"works for both versions: {a}")
works for older versions only
print(f"works only in old version: {[(x, y) for x in [1,2,3] for y in [3,1,4]]}")
The text was updated successfully, but these errors were encountered: