Closed Ark-kun closed 3 years ago
It's supposed to do that in order to preserve line numbers in error messages. Using to_empty
no longer guarantees that the column numbers are preserved, but line numbers are still supposed to be. The program purposely excludes stripping NL tokens (non-logical newlines) to achieve this.
Does the extra space cause problems? The code is still syntactically valid.
I added an option strip_nl
to strip NL tokens, too, but using that option no longer preserves line numbers. I pushed it to GitHub but it isn't yet on PyPI and isn't documented. I also fixed a limitation of annotated assignment stripping when they contained NL characters inside type annotations which were then stripped. The no_equal_move
option was added to disable that moving of the assignment line to fix the problem.
Docs are updated, and the new version has been pushed to PyPI.
Does the extra space cause problems? The code is still syntactically valid.
The problem for me was that this mangles YAML encoding.
YAML has some very nice-looking string encoding formats that preserve line endings. But the serializers switch to non-nice JSON-like string formats when there are any trailing whitespace characters.
When the function has multiline return type annotation, the stripped version has multiple spaces after the
:
symbol (the original function has none).