Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"typescript": "^5.3.2"
},
"dependencies": {
"@dylibso/xtp-bindgen": "1.0.0-rc.8",
"@dylibso/xtp-bindgen": "1.0.0-rc.11",
"ejs": "^3.1.10"
}
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function toPythonType(property: Property): string {
}

if (!tp) throw new Error("Cant convert property to Python type: " + property.type)
if (!property.nullable) return tp
if (!property.nullable && !property.required) return tp
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to decide what the logic should be here and if extism.Json is able to distinguish b/w null and optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zshipko is there an equivalent of omitempty for the json encoder? We may want to skip the key if the value is None and the type is !required

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really, I think the best way to handle nullable is to make the field Optional[T] and for non-required we can do the same, but a default value for that field in the dataclass.

I haven't totally thought it through but that should work.

return `Optional[${tp}]`
}

Expand Down