fix: handle decorators after snakecode#185
Conversation
Codecov Report
@@ Coverage Diff @@
## master #185 +/- ##
=======================================
Coverage 98.12% 98.12%
=======================================
Files 12 12
Lines 1014 1014
Branches 222 222
=======================================
Hits 995 995
Misses 10 10
Partials 9 9
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Will review this in the next few days |
There was a problem hiding this comment.
Yes! This is the right fix IMO.
I wanted to check that this wasn't a 'hack'
But is correct - python's tokenizer parses '@' as an operator (tokenize.OP) because it's actually a matrix multiplication operator, as well as being used for function decoration.
So '@' used to end up in the buffer that was flushed in the case of a context_exit triggered specifically after a run block. This left black failing to parse a lone @. (Note after something like input:, buffer used to still contain a lone '@' but buffer flushing would not be triggered as context_exit is not called). Now we force '@' not to be present in the flushed buffer when calling context_exit (i.e. exiting a run block). We do return a Status containing @ though, but that's OK as it won't be recognised as a keyword, and we'll just continue parsing the snakefile.
Wrote this as a documentation if we ever come back to it.
Nice fix! 👍
|
Ah didn't realise it was a matrix multiplication operator. I was confused as to why it was returned as an OP token. Cheers! |
Closes #144