The following statement causes flynt to crash on what it thinks is an EOF in multiline string. Removing the degree symbol (°) results in output as expected:
Skipping fstrings transform of file <code> due to ('EOF in multi-line statement', (2, 0)).
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flynt/api.py", line 93, in fstringify_code
new_code, changes = fstringify_code_by_line(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flynt/code_editor.py", line 238, in fstringify_code_by_line
return _transform_code(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flynt/code_editor.py", line 278, in _transform_code
).edit()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flynt/code_editor.py", line 71, in edit
self.try_chunk(chunk)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flynt/code_editor.py", line 129, in try_chunk
if contains_comment(self.code_in_chunk(chunk)):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flynt/utils/utils.py", line 132, in contains_comment
for token in tokens:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tokenize.py", line 523, in _tokenize
raise TokenError("EOF in multi-line statement", (lnum, 0))
tokenize.TokenError: ('EOF in multi-line statement', (2, 0))
print("Feels like: {}°F".format(data["main"]["feels_like"]))
The following statement causes flynt to crash on what it thinks is an EOF in multiline string. Removing the degree symbol (°) results in output as expected:
flynt -v -s 'print("Feels like: {}°F".format(data["main"]["feels_like"]))'
Output from the above:
Output with degree symbol removed:
As you'd expect, the results are the same when processing that statement as part of a file.