Skip to content

Commit

Permalink
fix: only import when there are imports (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
zshipko authored Oct 9, 2024
1 parent 21fbea6 commit d53e56c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions template/plugin/__init__.py.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import extism # pyright: ignore
import plugin

<% if (Object.values(schema.schemas).length > 0){ %>
from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.name).join(", ") %> # noqa: F401
<% } %>

# Imports

Expand Down
3 changes: 3 additions & 0 deletions template/plugin/pdk_imports.py.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# THIS FILE WAS GENERATED BY `xtp-python-bindgen`. DO NOT EDIT.

import extism # noqa: F401 # pyright: ignore

<% if (Object.values(schema.schemas).length > 0) { %>
from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.name).join(", ") %> # noqa: F401
<% } %>

<% schema.imports.forEach(imp => { %>
<% if (hasComment(imp)) -%>
Expand Down
4 changes: 4 additions & 0 deletions template/plugin/plugin.py.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import extism # noqa: F401 # pyright: ignore
<% if (Object.values(schema.schemas).length > 0) { %>
from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.name).join(", ") %> # noqa: F401
<% } %>
<% if (schema.imports.length > 0) { %>
from pdk_imports import <%- schema.imports.map(schema => camelToSnakeCase(schema.name)).join(", ") %> # noqa: F401
<% } %>
from typing import List, Optional # noqa: F401

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

0 comments on commit d53e56c

Please sign in to comment.