Skip to content

Commit d53e56c

Browse files
author
zach
authored
fix: only import when there are imports (#5)
1 parent 21fbea6 commit d53e56c

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

template/plugin/__init__.py.ejs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import extism # pyright: ignore
44
import plugin
5+
6+
<% if (Object.values(schema.schemas).length > 0){ %>
57
from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.name).join(", ") %> # noqa: F401
8+
<% } %>
69

710
# Imports
811

template/plugin/pdk_imports.py.ejs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# THIS FILE WAS GENERATED BY `xtp-python-bindgen`. DO NOT EDIT.
22

33
import extism # noqa: F401 # pyright: ignore
4+
5+
<% if (Object.values(schema.schemas).length > 0) { %>
46
from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.name).join(", ") %> # noqa: F401
7+
<% } %>
58

69
<% schema.imports.forEach(imp => { %>
710
<% if (hasComment(imp)) -%>

template/plugin/plugin.py.ejs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import extism # noqa: F401 # pyright: ignore
2+
<% if (Object.values(schema.schemas).length > 0) { %>
23
from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.name).join(", ") %> # noqa: F401
4+
<% } %>
5+
<% if (schema.imports.length > 0) { %>
36
from pdk_imports import <%- schema.imports.map(schema => camelToSnakeCase(schema.name)).join(", ") %> # noqa: F401
7+
<% } %>
48
from typing import List, Optional # noqa: F401
59

610
<% schema.exports.forEach(ex => { -%>

0 commit comments

Comments
 (0)