@@ -274,7 +274,7 @@ def compat(self, token, iterable): |
274 | 274 | toks_append = self.tokens.append |
275 | 275 | startline = token[0] in (NEWLINE, NL) |
276 | 276 | prevstring = False |
277 | | - in_fstring = 0 |
| 277 | + in_fstring_or_tstring = 0 |
278 | 278 |
|
279 | 279 | for tok in _itertools.chain([token], iterable): |
280 | 280 | toknum, tokval = tok[:2] |
@@ -293,10 +293,10 @@ def compat(self, token, iterable): |
293 | 293 | else: |
294 | 294 | prevstring = False |
295 | 295 |
|
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 |
300 | 300 | if toknum == INDENT: |
301 | 301 | indents.append(tokval) |
302 | 302 | continue |
@@ -311,8 +311,8 @@ def compat(self, token, iterable): |
311 | 311 | elif toknum in {FSTRING_MIDDLE, TSTRING_MIDDLE}: |
312 | 312 | tokval = self.escape_brackets(tokval) |
313 | 313 |
|
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: |
316 | 316 | tokval = ' ' + tokval |
317 | 317 |
|
318 | 318 | # Insert a space between two consecutive f-strings |
|