Fix python type annotation output when not enabled (#7983)

Fixes #7971

Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
Aaron Barany
2023-11-29 09:58:21 -08:00
committed by GitHub
parent da55ac3a27
commit 5ba80c24e0
11 changed files with 48 additions and 44 deletions

View File

@@ -815,8 +815,12 @@ class PythonGenerator : public BaseGenerator {
if (!parser_.opts.one_file && !parser_.opts.python_no_type_prefix_suffix) {
// Generate method without struct name.
code += "def Start" + field_method +
"Vector(builder, numElems: int) -> int:\n";
if (parser_.opts.python_typing) {
code += "def Start" + field_method +
"Vector(builder, numElems: int) -> int:\n";
} else {
code += "def Start" + field_method + "Vector(builder, numElems):\n";
}
code += Indent + "return " + struct_type + "Start";
code += field_method + "Vector(builder, numElems)\n\n";
}