File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,16 @@ def _tokenize(f):
8989 last_end = tok .end
9090 if tok .type in [std_tokenize .NEWLINE , std_tokenize .NL ]:
9191 last_end = (tok .end [0 ] + 1 , 0 )
92+ elif (
93+ sys .version_info >= (3 , 12 )
94+ and tok .type == std_tokenize .FSTRING_MIDDLE
95+ ):
96+ last_end = (
97+ last_end [0 ],
98+ last_end [1 ]
99+ + tok .string .count ("{" )
100+ + tok .string .count ("}" )
101+ )
92102
93103
94104def _untokenize (tokens ):
@@ -134,6 +144,12 @@ class CustomRule(unasync.Rule):
134144 tokval [:1 ], tokval [1 :- 1 ], tokval [- 1 :]
135145 tokval = \
136146 left_quote + self ._unasync_string (name ) + right_quote
147+ elif (
148+ sys .version_info >= (3 , 12 )
149+ and toknum == std_tokenize .FSTRING_MIDDLE
150+ ):
151+ tokval = tokval .replace ("{" , "{{" ).replace ("}" , "}}" )
152+ tokval = self ._unasync_string (tokval )
137153 if used_space is None :
138154 used_space = space
139155 yield (used_space , tokval )
You can’t perform that action at this time.
0 commit comments