You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The program should remove all the whitespace, but the problem is that it works at the level of the Python tokenizer/untokenizer. The tokens for type hints have their strings converted to empty strings, but the space before the hints is still restored by untokenize. I briefly looked into the issue a while back, but I didn't come up with a quick fix. The Python untokenize function does not guarantee round-trip untokenizing for whitespace between tokens.
The program works at the tokenizer level, by changing or setting empty the strings associated with certain tokens in order to strip them. When the Python untokenizer is called to piece the tokens back together into text it sometimes adds whitespace. It's done by the algorithm in the Python library, and cannot be changed.
One option might be to simply drop certain tokens rather than changing the string associated with them, but strip-hints isn't currently designed that way. This might also lead to edge cases where the untokenizer would do other unexpected things or raise exceptions.
Running
strip-hints --inplace --to-empty getnonce.py
on https://github.com/nyuszika7h/getnonce has the following result:I would expect all redundant whitespace before commas, closing parentheses, colons, etc. to be removed.
Environment:
The text was updated successfully, but these errors were encountered: