Open nilshamerlinck opened 7 years ago
Hello,
Thanks for reporting, this is actually a variation of this bug https://github.com/PyCQA/baron/issues/11 which is a weakness of the current parser which is based a bit too much on the original python grammar which doesn't takes comments into account.
@Psycojoker Any suggestions for how I could get started on fixing this?
Running into this as well...
@rowillia I've been thinking about it a bit and well... I'm not expecting this to be simple to fix (things are always more complexe than expected in red/baron).
My current intuition is that the rule to introduce the DEDENT token here https://github.com/PyCQA/baron/blob/a3cc187099c3a3a07a1869dc7f203535ade974df/baron/indentation_marker.py#L79-L86 should do that only when it encounter or will encounter a token that is not related to formatting. Or this whole process should only take into account indentation related lines that have meaningful codes on it.
But to be honest it's been quite a long time since I've looked at this part of the code (so my intuition might not be accurate) and I really have problems going back on that project after the big burnout I've made on it :/
Ok, the fix was ridiculously simple, I regret taking so much time to dig into this https://github.com/PyCQA/baron/commit/bca4d4296b7a0442821075819e5b0a1ca7f145a3
@nilshamerlinck @rowillia @Thijs-Riezebeek can you test this and tell me if this solves your situation plz?
No one :x ?
@Psycojoker thanks for the fix, it works :)
First case:
Triggers:
Second case:
Triggers:
Both snippets are parsed without error if I remove the second comment: