-
Notifications
You must be signed in to change notification settings - Fork 29
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
fix: Lambda keyword args, improve errors, and nested madness #136
Conversation
feat: add template_engine keyword in order to support Snakemake 7
chore: release 0.6.0
Okay, I have been working on this locally for a day or two. What seems to be the problem (I think) is that after When I walked through the example in pycharm's debugger I noticed that Maybe when we get to a comment token we need to explicitly look back and see if we missed a DEDENT? Any thoughts @bricoletc? |
Codecov Report
@@ Coverage Diff @@
## dev #136 +/- ##
==========================================
+ Coverage 98.20% 98.25% +0.04%
==========================================
Files 12 12
Lines 949 973 +24
Branches 211 216 +5
==========================================
+ Hits 932 956 +24
Misses 10 10
Partials 7 7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Okay, I got to the bottom of it....and then I made the test case more complicated and found some more bugs....and then fixed those (I hope). The crux of the issue was really that tokenize skips comments and mixed in with that was that if there is a dedent near a comment then this was causing some issues with the code indent counters. Even though I made the MWE test from #126 more complicated, it would be great to get some more robust testing though. |
Hey mbhall88, I've run this branch on our snakemake package, and am already loving the logging improvements! The specific case of #126 is fixed (:tada:). Unfortunately I did find more nesting-related issues. In the MWEs below I use if True:
ruleorder: A > B
mylist = [] # you can even remove the indentation from this line
mystr = "a" # error occurs in the 2nd line of code below a nested ruleorder Additional empty lines, comment lines and if True:
ruleorder: A > B
def myfunc():
pass
mylist=[] Similarly, empty lines, comment lines and Good hunting! |
Thank you so much for this thorough testing @siebrenf. I'll schedule some time next week to try and get to the bottom of this. Happy for anyone else to have a go in the meantime though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need one change to get the comment indenting right, see comments
snakefmt/parser/syntax.py
Outdated
else: | ||
buffer += f"{TAB * comment_indent}{token.string}" | ||
prev_token = token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here the comment above applies with respect to TAB
arithmetic, and using self.cur_indent
+ token lookahead instead
All issues mentioned above were fixed! Buuuut I did find one new issue: if True:
rule with_run_directive:
output:
test.txt
run:
if True:
print("this line is in the error")
print("the indenting on this line matters") which causes [ERROR] In file "test.smk": InvalidPython: Black error:
'''
Cannot parse: 8:0: print("this line is in the error")
''' The error is gone if the first line of the |
@siebrenf you're a great test case generator!! Latest commit fixes your last issue. Do you mind testing again? |
Thanks, I'll put that on my resume! But for real, it's awesome what you do with it! All nesting issues have been resolved! |
@johanneskoester did you change the merging options for the repository? I can only squash and merge this PR as all other options are "not enabled for this repository". I'd rather rebase this as there is quite a bit of work. Do you mind if I change it back to allow at least rebasing? |
Thanks for all the testing @siebrenf :) |
@mbhall88 can now rebase- totally agree this should not be a squash |
Added
retries
keyword [closes feat: add retries to grammar #145]Fixed