@@ -274,7 +274,7 @@ def compat(self, token, iterable):
274274 toks_append = self .tokens .append
275275 startline = token [0 ] in (NEWLINE , NL )
276276 prevstring = False
277- in_fstring = 0
277+ in_fstring_or_tstring = 0
278278
279279 for tok in _itertools .chain ([token ], iterable ):
280280 toknum , tokval = tok [:2 ]
@@ -293,10 +293,10 @@ def compat(self, token, iterable):
293293 else :
294294 prevstring = False
295295
296- if toknum == FSTRING_START :
297- in_fstring += 1
298- elif toknum == FSTRING_END :
299- in_fstring -= 1
296+ if toknum in { FSTRING_START , TSTRING_START } :
297+ in_fstring_or_tstring += 1
298+ elif toknum in { FSTRING_END , TSTRING_END } :
299+ in_fstring_or_tstring -= 1
300300 if toknum == INDENT :
301301 indents .append (tokval )
302302 continue
@@ -311,8 +311,8 @@ def compat(self, token, iterable):
311311 elif toknum in {FSTRING_MIDDLE , TSTRING_MIDDLE }:
312312 tokval = self .escape_brackets (tokval )
313313
314- # Insert a space between two consecutive brackets if we are in an f-string
315- if tokval in {"{" , "}" } and self .tokens and self .tokens [- 1 ] == tokval and in_fstring :
314+ # Insert a space between two consecutive brackets if we are in an f-string or t-string
315+ if tokval in {"{" , "}" } and self .tokens and self .tokens [- 1 ] == tokval and in_fstring_or_tstring :
316316 tokval = ' ' + tokval
317317
318318 # Insert a space between two consecutive f-strings
0 commit comments