Skip to content

Commit f1af5b1

Browse files
authored
feat: add void to PythonConverible (#57)
1 parent 025e9da commit f1af5b1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/python.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface PythonProxy {
6161
export type PythonConvertible =
6262
| number
6363
| bigint
64+
| void
6465
| null
6566
| undefined
6667
| boolean
@@ -434,7 +435,7 @@ export class PyObject {
434435
}
435436

436437
case "object": {
437-
if (v === null) {
438+
if (v === null /*or void*/) {
438439
return python.builtins.None[ProxiedPyObject];
439440
} else if (ProxiedPyObject in v) {
440441
const proxy = v as PythonProxy;

test/test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,21 @@ def call(cb):
298298
cb.destroy();
299299
});
300300

301+
Deno.test("callback returns void", () => {
302+
const { call } = python.runModule(
303+
`
304+
def call(cb):
305+
cb()
306+
`,
307+
"cb_test.py",
308+
);
309+
const cb = python.callback(() => {
310+
// return void
311+
});
312+
call(cb);
313+
cb.destroy();
314+
});
315+
301316
Deno.test("exceptions", async (t) => {
302317
await t.step("simple exception", () => {
303318
assertThrows(() => python.runModule("1 / 0"));

0 commit comments

Comments
 (0)