ikamensh / flynt

A tool to automatically convert old string literal formatting to f-strings
MIT License
689 stars 33 forks source link

No conversion happens for raw (r) strings #167

Open patrickdepinguin opened 1 year ago

patrickdepinguin commented 1 year ago

Strings that have a 'r' (raw) prefix are not converted by flynt.

$ flynt -s "'foo {0} bar'.format(baz)"                                                                                                                              
f'foo {baz} bar'
$ flynt -s "r'foo {0} bar'.format(baz)"                                                                                                                                 
r'foo {0} bar'.format(baz)

$ flynt --version                                         
0.77

Expected conversion would have prefix rf or fr .

wimglenn commented 2 months ago

I hit this one too. It's unfortunate for regex, which are almost always raw strings out of habit (even when they don't need to be), e.g.

import re
pat0 = re.compile(r".*")
pat1 = re.compile(r"foo/{}?".format(pat0))