lark
lark copied to clipboard
A fix for black formatter breaking standalone parser generation.
Here lies a fix for Lark's standalone parser generation breaking when Lark is run through the black formatter. The fix simply entails stripping lines as they are iterated through in the extract_sections function in standlone.py.
Closes #1362
Or... You don't run black on this codebase, which in this case destroys information. I presume the problem is that black indents the comments, which is just wrong behavior since the comments do act on a global scope.
@MegaIng Thats correct, the comments get tabbed in with black, however the strip fix appears to correct the issue for both Lark proper and standalone. Doesn't hurt to make the implementation more black friendly.
@marsninja Why not just run black after the standalone has been generated?
@MegaIng Thats correct, the comments get tabbed in with black, however the
stripfix appears to correct the issue for both Lark proper and standalone. Doesn't hurt to make the implementation more black friendly.
Sure, it technically doesn't hurt. But it is extra code, and it allows something that currently isn't allowed, with good reasons. Having those comments be indented is confusing for human parsers, so it shouldn't be allowed. Considering the alternative solution to this "issue" is "just don't do the thing that breaks it, there is no reason to do it", I don't see why we should add this.
@marsninja Please address the concerns of the maintainers, or I will close this PR. Thanks.
Here is something