@@ -458,20 +458,24 @@ class SyncTransformer(ast.NodeTransformer):
458
458
def visit_Await (self , node : ast .Await ):
459
459
return self .generic_visit (node .value )
460
460
461
- def replace_async (self , node : ast .AST , target : type [ast .AST ]) -> ast .AST :
461
+ def replace_async (
462
+ self , node : ast .AST , target : type [ast .AST ], * args : object
463
+ ) -> ast .AST :
462
464
node = self .generic_visit (node )
463
- newnode = target ()
465
+ # py313 gives DeprecationWarning if missing posargs, so we pass them even if we
466
+ # overwrite __dict__ directly afterwards
467
+ newnode = target (* args )
464
468
newnode .__dict__ = node .__dict__
465
469
return newnode
466
470
467
- def visit_AsyncFunctionDef (self , node : ast .AST ):
468
- return self .replace_async (node , ast .FunctionDef )
471
+ def visit_AsyncFunctionDef (self , node : ast .AsyncFunctionDef ):
472
+ return self .replace_async (node , ast .FunctionDef , node . name , node . args )
469
473
470
- def visit_AsyncWith (self , node : ast .AST ):
474
+ def visit_AsyncWith (self , node : ast .AsyncWith ):
471
475
return self .replace_async (node , ast .With )
472
476
473
- def visit_AsyncFor (self , node : ast .AST ):
474
- return self .replace_async (node , ast .For )
477
+ def visit_AsyncFor (self , node : ast .AsyncFor ):
478
+ return self .replace_async (node , ast .For , node . target , node . iter )
475
479
476
480
477
481
@pytest .mark .parametrize (("test" , "path" ), test_files )
0 commit comments