Skip to content
Snippets Groups Projects
Commit f552d5fe authored by Laurent Peuch's avatar Laurent Peuch
Browse files

[fix] missing case for raw f-strings

parent f1f8136d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -54,7 +54,7 @@ def group_generator(sequence):
current += next(iterator)
if current in list('uUfFrRbB') and str(iterator.show_next()).startswith(('"', "'")):
current += next(iterator)
if str(current).lower() in ["ur", "br", "fr"] and str(iterator.show_next()).startswith(('"', "'")):
if str(current).lower() in ["ur", "br", "fr", "rf"] and str(iterator.show_next()).startswith(('"', "'")):
current += next(iterator)
if any([re.match(x, current) for x in (r'^\d+[eE]$', r'^\d+\.\d*[eE]$', r'^\.\d+[eE]$')]):
current += next(iterator)
Loading
Loading
Loading
Loading
@@ -86,6 +86,7 @@ TOKENS = (
(r'[uU][rR]["\'](.|\n|\r)*["\']', 'UNICODE_RAW_STRING'),
(r'[bB][rR]["\'](.|\n|\r)*["\']', 'BINARY_RAW_STRING'),
(r'[fF][rR]["\'](.|\n|\r)*["\']', 'INTERPOLATED_RAW_STRING'),
(r'[rR][fF]["\'](.|\n|\r)*["\']', 'INTERPOLATED_RAW_STRING'),
)
 
 
Loading
Loading
Loading
Loading
@@ -329,6 +329,15 @@ def test_interpolated_raw_string():
match("FR'{(lambda x: x*2)(3)}'", 'INTERPOLATED_RAW_STRING')
match("FR'{(lambda x: x*2)(3)}'", 'INTERPOLATED_RAW_STRING')
 
match("rf'He said his name is {name!r}.'", 'INTERPOLATED_RAW_STRING')
match("rf'The value is {value}.'", 'INTERPOLATED_RAW_STRING')
match('rF"He said his name is {name!r}."', 'INTERPOLATED_RAW_STRING')
match('Rf"The value is {value}."', 'INTERPOLATED_RAW_STRING')
match("RF'{date} was on a {date:%A}'", 'INTERPOLATED_RAW_STRING')
match("rf'a={d[\"a\"]}'", 'INTERPOLATED_RAW_STRING')
match("RF'{(lambda x: x*2)(3)}'", 'INTERPOLATED_RAW_STRING')
match("RF'{(lambda x: x*2)(3)}'", 'INTERPOLATED_RAW_STRING')
 
def test_raw_string():
match('r"pouet pouet"', 'RAW_STRING')
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment