Open chendo opened 1 year ago
Good catch, thank you. I agree, that we should strip them consistently.
Re-labeling this as Enhancement. I found the problem with the behaviour above is that it indeed is standard python behaviour, which we inherit by being a superset. I still agree we should provide slightly different behaviour though.
One way is to always dedent with textwrap
, e.g. when you do something like
if True:
"""\
This should also have no spaces in front.
There should be no spaces after this.
"""
we can automatically remove the indendentation. Note however, the additional NL and \
backslash at the beginning of the multi-line string. Without this, the dedentation does not work, as the first line in the original code snippet would always be counted as an indentation of 0.
Another conflict that comes up, is the use case of actually wanting that indentation, e.g. when you write query code that templates indentation-sensitive source code, e.g. for Python code generation. In that case, we also want to offer a way to explicitly insert indentation, which should not be stripped away.
I am open for ideas here, still thinking about the best way to do it.
This may be a good first issue work on, however, it will require some language-level design thinking. The goal should really be to have something intuitive and minimally-breaking with respect to previous versions.
Revision: v0.7b2
It appears LMQL docstrings are not stripping trailing spaces when docstrings aren't at the root level for a particular scope.
Complies to:
Note the trailing spaces in docstrings defined in for loops. I would expect these trailing spaces to not be there.