Skip to content

Commit bc0bd9c

Browse files
author
zach
authored
fix: add doc comments to exports/implementation functions, fix pyright type checking (#2)
1 parent aa91509 commit bc0bd9c

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

template/plugin/__init__.py.ejs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.nam
1616
# And it returns an output <%- toPythonType(imp.output) %> (<%- formatCommentLine(imp.output.description) %>)
1717
<% } -%>
1818
@extism.import_fn("extism:host/user", "<%- imp.name %>")
19-
def <%- camelToSnakeCase(imp.name) %>(<% if (imp.input) { -%>input: <%- toPythonType(imp.input) %><%} -%>) <% if (imp.output) { %> -> <%- toPythonType(imp.output) %><% } %>:
19+
def <%- camelToSnakeCase(imp.name) %>(<% if (imp.input) { -%>input: <%- toPythonType(imp.input) %><%} -%>) <% if (imp.output) { %> -> <%- toPythonType(imp.output) %><% } %>: # pyright: ignore [reportReturnType]
2020
pass
2121
<% }) %>
2222

2323
# Exports
24+
# The implementations for these functions is in `plugin.py`
2425

2526
<% schema.exports.forEach(ex => { -%>
27+
<% if (hasComment(ex)) { -%>
28+
# <%- formatCommentBlock(ex.description, "# ") %>
29+
<% } -%>
2630
@extism.plugin_fn
2731
def <%- ex.name %>():
2832
res = plugin.<%- camelToSnakeCase(ex.name) %>(<% if (ex.input) { %> extism.input(<%- toPythonType(ex.input) %>) <% } %>)

template/plugin/pdk_imports.py.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.nam
1313
# And it returns an output <%- toPythonType(imp.output) %> (<%- formatCommentLine(imp.output.description) %>)
1414
<% } -%>
1515
@extism.import_fn("extism:host/user", "<%- imp.name %>")
16-
def <%- camelToSnakeCase(imp.name) %>(<% if (imp.input) { -%>input: <%- toPythonType(imp.input) %><%} -%>) <% if (imp.output) { %> -> <%- toPythonType(imp.output) %><% } %>:
16+
def <%- camelToSnakeCase(imp.name) %>(<% if (imp.input) { -%>input: <%- toPythonType(imp.input) %><%} -%>) <% if (imp.output) { %> -> <%- toPythonType(imp.output) %><% } %>: # pyright: ignore [reportReturnType]
1717
pass
1818
<% }) %>
1919

template/plugin/plugin.py.ejs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ from pdk_imports import <%- schema.imports.map(schema => camelToSnakeCase(schema
44
from typing import List, Optional # noqa: F401
55

66
<% schema.exports.forEach(ex => { -%>
7+
<% if (hasComment(ex)) { -%>
8+
# <%- formatCommentBlock(ex.description, "# ") %>
9+
<% } -%>
710
def <%- camelToSnakeCase(ex.name) %>(<% if (ex.input) { %>input: <%- toPythonType(ex.input) %> <% } %>) <% if (ex.output) {%>-> <%- toPythonType(ex.output) %><%}%>:
811
<% if (featureFlags['stub-with-code-samples'] && codeSamples(ex, 'python').length > 0) { -%>
912
<%- codeSamples(ex, 'python')[0].source %>

0 commit comments

Comments
 (0)