Skip to content

Commit

Permalink
Avoid outputting Python files for already generated types
Browse files Browse the repository at this point in the history
This may overwrite types that have already been generated and can create
unwanted empty files. Fixes #8490
  • Loading branch information
akb825 committed Jan 24, 2025
1 parent 4b69b27 commit fae7554
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 32 deletions.
11 changes: 4 additions & 7 deletions src/idl_gen_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions tests/FromInclude.py

This file was deleted.

5 changes: 0 additions & 5 deletions tests/MyGame/OtherNameSpace/FromInclude.py

This file was deleted.

5 changes: 0 additions & 5 deletions tests/MyGame/OtherNameSpace/TableB.py

This file was deleted.

5 changes: 0 additions & 5 deletions tests/MyGame/OtherNameSpace/Unused.py

This file was deleted.

Empty file.
5 changes: 0 additions & 5 deletions tests/TableA.py

This file was deleted.

Empty file removed tests/__init__.py
Empty file.

0 comments on commit fae7554

Please sign in to comment.