Skip to content

Commit 992f2b9

Browse files
committed
fix: create __init__.py in generated module
1 parent 41a9ad4 commit 992f2b9

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

frost_sta_client/odata_codegen/generator.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,15 +1371,11 @@ def snake(name: str) -> str:
13711371
lines.append("")
13721372
lines.append("")
13731373

1374+
os.makedirs(out_dir, exist_ok=True)
13741375
# Also write a package __init__.py so that `import <output-dir> as model` works as in README.
13751376
init_path = os.path.join(out_dir, "__init__.py")
1376-
try:
1377-
with open(init_path, "w", encoding="utf-8") as fh:
1378-
fh.write(f"from .{module_name} import *\n")
1379-
except Exception:
1380-
# Non-fatal: importing via <out_dir>.<module_name> will still work
1381-
pass
1382-
os.makedirs(out_dir, exist_ok=True)
1377+
with open(init_path, "w", encoding="utf-8") as fh:
1378+
fh.write(f"from .{module_name} import *\n")
13831379
out_path = os.path.join(out_dir, f"{module_name}.py")
13841380
with open(out_path, "w", encoding="utf-8") as fh:
13851381
fh.write("\n".join(lines) + "\n")

0 commit comments

Comments
 (0)