From 9d1a3bb338c77c6701f4517ed7f81cc5e2662a61 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 12 Jul 2025 07:44:04 +0200 Subject: [PATCH] chore(async-to-sync): handle generator expressions --- tools/async_to_sync.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/async_to_sync.py b/tools/async_to_sync.py index e3c4b04cf..888417abe 100755 --- a/tools/async_to_sync.py +++ b/tools/async_to_sync.py @@ -264,6 +264,16 @@ class AsyncToSync(ast.NodeTransformer): # type: ignore self.generic_visit(node) return node + def visit_GeneratorExp(self, node: ast.GeneratorExp) -> ast.AST: + if isinstance(node.elt, ast.Await): + node.elt = node.elt.value + + for gen in node.generators: + if gen.is_async: + gen.is_async = 0 + + return node + class RenameAsyncToSync(ast.NodeTransformer): # type: ignore names_map = { -- 2.47.3