Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bin/make-unasync
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ def _tokenize(f):
last_end = tok.end
if tok.type in [std_tokenize.NEWLINE, std_tokenize.NL]:
last_end = (tok.end[0] + 1, 0)
elif (
sys.version_info >= (3, 12)
and tok.type == std_tokenize.FSTRING_MIDDLE
):
last_end = (
last_end[0],
last_end[1]
+ tok.string.count("{")
+ tok.string.count("}")
)


def _untokenize(tokens):
Expand Down Expand Up @@ -134,6 +144,12 @@ class CustomRule(unasync.Rule):
tokval[:1], tokval[1:-1], tokval[-1:]
tokval = \
left_quote + self._unasync_string(name) + right_quote
elif (
sys.version_info >= (3, 12)
and toknum == std_tokenize.FSTRING_MIDDLE
):
tokval = tokval.replace("{", "{{").replace("}", "}}")
tokval = self._unasync_string(tokval)
if used_space is None:
used_space = space
yield (used_space, tokval)
Expand Down