twosigma / flint

A Time Series Library for Apache Spark
Apache License 2.0
993 stars 184 forks source link

bug: incorrect parsing in certain strings #84

Closed neutrinoceros closed 4 years ago

neutrinoceros commented 4 years ago

I've seen some lines using "%" formatting that weren't affected by flynt. Here's my best attempt to reproduce the problem in a minimal form:

from flynt.api import fstringify_code_by_line

# this works perfectly
fstringify_code_by_line("""'%s' % (fn(var),)""", multiline=False, len_limit=100)
>> ("f'{fn(var)}'", 1)

# and this doesn't (it should produce the same result as the first case)
fstringify_code_by_line("""'%s' % fn(var)""", multiline=False, len_limit=100)
>> ("'%s' % fn(var)", 0)
neutrinoceros commented 4 years ago

I'm sorry this has nothing to do with this repo, it belongs to flynt. Closing.