Avoid outputting Python files for already generated types (#8500)

This may overwrite types that have already been generated and can create
unwanted empty files. Fixes #8490
This commit is contained in:
Aaron Barany
2025-06-23 12:00:37 -07:00
committed by GitHub
parent a2916d37e7
commit dfd92124aa
8 changed files with 4 additions and 32 deletions

View File

@@ -2686,14 +2686,11 @@ class PythonGenerator : public BaseGenerator {
bool SaveType(const std::string &defname, const Namespace &ns,
const std::string &classcode, const ImportMap &imports,
const std::string &mod, bool needs_imports) const {
if (classcode.empty()) return true;
std::string code = "";
if (classcode.empty()) {
BeginFile(LastNamespacePart(ns), false, &code, "", {});
code += "# NOTE " + defname + " does not declare any structs or enums\n";
} else {
BeginFile(LastNamespacePart(ns), needs_imports, &code, mod, imports);
code += classcode;
}
BeginFile(LastNamespacePart(ns), needs_imports, &code, mod, imports);
code += classcode;
const std::string directories =
parser_.opts.one_file ? path_ : namer_.Directories(ns.components);

View File

@@ -1,5 +0,0 @@
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: OtherNameSpace
# NOTE FromInclude.py does not declare any structs or enums

View File

@@ -1,5 +0,0 @@
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: OtherNameSpace
# NOTE FromInclude.py does not declare any structs or enums

View File

@@ -1,5 +0,0 @@
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: OtherNameSpace
# NOTE TableB.py does not declare any structs or enums

View File

@@ -1,5 +0,0 @@
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: OtherNameSpace
# NOTE Unused.py does not declare any structs or enums

View File

@@ -1,5 +0,0 @@
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
# NOTE TableA.py does not declare any structs or enums

View File