From 6fb8d8864c5b085bb4af4376b5e65204e9112c42 Mon Sep 17 00:00:00 2001 From: Arian van Dorsten Date: Wed, 16 Apr 2025 12:36:50 +0200 Subject: [PATCH] Have an output file for every class with the name of the class instead of a __init__.py. Now we can parse a tree of .proto files with multiple .proto files in each sub dir without overwriting the __init__.py with every invocation of the compiler --- src/betterproto/plugin/parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/betterproto/plugin/parser.py b/src/betterproto/plugin/parser.py index 5f7b72c4..92c7f85d 100644 --- a/src/betterproto/plugin/parser.py +++ b/src/betterproto/plugin/parser.py @@ -151,8 +151,10 @@ def generate_code(request: CodeGeneratorRequest) -> CodeGeneratorResponse: if not output_package.output: continue + output_name = output_package.package_proto_obj.name.split('/')[-1].split('.')[0] + ".py" + # Add files to the response object - output_path = pathlib.Path(*output_package_name.split("."), "__init__.py") + output_path = pathlib.Path(*output_package_name.split("."), output_name) output_paths.add(output_path) response.file.append(