From 945aae4a7862d7dc4bca664bfeb3f25faae62b2e Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Thu, 5 Jun 2025 13:38:39 -0400 Subject: [PATCH] refactor: rename internal field `returns` into `return_` Signed-off-by: Louis Mandel --- src/pdl/pdl_ast.py | 2 +- src/pdl/pdl_ast_utils.py | 4 ++-- src/pdl/pdl_dumper.py | 2 +- src/pdl/pdl_interpreter.py | 2 +- src/pdl/pdl_parser.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pdl/pdl_ast.py b/src/pdl/pdl_ast.py index a25c64a7f..1aa706f8d 100644 --- a/src/pdl/pdl_ast.py +++ b/src/pdl/pdl_ast.py @@ -357,7 +357,7 @@ class FunctionBlock(LeafBlock): function: Optional[dict[str, PdlTypeType]] """Functions parameters with their types. """ - returns: "BlockType" = Field(..., alias="return") + return_: "BlockType" = Field(..., alias="return") """Body of the function. """ signature: Optional[Json] = None diff --git a/src/pdl/pdl_ast_utils.py b/src/pdl/pdl_ast_utils.py index 9680f8772..f7e28d564 100644 --- a/src/pdl/pdl_ast_utils.py +++ b/src/pdl/pdl_ast_utils.py @@ -38,7 +38,7 @@ def iter_block_children(f: Callable[[BlockType], None], block: BlockType) -> Non f(blocks) match block: case FunctionBlock(): - f(block.returns) + f(block.return_) case CallBlock(): if block.pdl__trace is not None: f(block.pdl__trace) @@ -124,7 +124,7 @@ def map_block_children(f: MappedFunctions, block: BlockType) -> BlockType: block = block.model_copy(update={"defs": defs}) match block: case FunctionBlock(): - block.returns = f.f_block(block.returns) + block.return_ = f.f_block(block.return_) case CallBlock(): block.call = f.f_expr(block.call) block.args = f.f_expr(block.args) diff --git a/src/pdl/pdl_dumper.py b/src/pdl/pdl_dumper.py index eddea82a0..4a2e31c47 100644 --- a/src/pdl/pdl_dumper.py +++ b/src/pdl/pdl_dumper.py @@ -247,7 +247,7 @@ def block_to_dict( # noqa: C901 d["function"] = None else: d["function"] = {x: type_to_dict(t) for x, t in block.function.items()} - d["return"] = block_to_dict(block.returns, json_compatible) + d["return"] = block_to_dict(block.return_, json_compatible) # if block.scope is not None: # d["scope"] = scope_to_dict(block.scope, json_compatible) case CallBlock(): diff --git a/src/pdl/pdl_interpreter.py b/src/pdl/pdl_interpreter.py index 1d359b0a5..4a9534707 100644 --- a/src/pdl/pdl_interpreter.py +++ b/src/pdl/pdl_interpreter.py @@ -1859,7 +1859,7 @@ def process_call( ) if "pdl_context" in args: args["pdl_context"] = deserialize(args["pdl_context"]) - f_body = closure.returns + f_body = closure.return_ f_scope = ( (closure.pdl__scope or PdlDict({})) | PdlDict({"pdl_context": scope.data["pdl_context"]}) diff --git a/src/pdl/pdl_parser.py b/src/pdl/pdl_parser.py index 4bda95f9f..3752b36f3 100644 --- a/src/pdl/pdl_parser.py +++ b/src/pdl/pdl_parser.py @@ -104,7 +104,7 @@ def parse_dict( # block.fallback = set_block_location(block.fallback, append(loc, "fallback")) # match block: # case FunctionBlock(): -# block.returns = set_blocks_location(block.returns, append(loc, "return")) +# block.return_ = set_blocks_location(block.return_, append(loc, "return")) # case CallBlock(): # block.args = {x: set_expr_location(expr) for x, expr in block.args.items()} # case ModelBlock():