Skip to content

Commit f34e2b0

Browse files
committed
fix: annotate script()
To allow mypy to analyze typing for annotated functions. Otherwise it complains that "Untyped decorator makes function "ones_like" untyped [misc]" ghstack-source-id: 02f281c Pull Request resolved: #245
1 parent 66480d4 commit f34e2b0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

onnxscript/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import inspect
1010
import sys
1111
import textwrap
12+
from typing import Any, Callable, Optional
1213

1314
import onnx.helper
1415

@@ -52,7 +53,9 @@ def script_check(f: ast.FunctionDef, opset, global_names, source, default_opset=
5253
return convert.top_level_stmt(f)
5354

5455

55-
def script(opset=None, default_opset=None, **kwargs):
56+
def script(
57+
opset: Optional[values.Opset] = None, default_opset: Optional[Any] = None, **kwargs: Any
58+
) -> Callable[[Callable[..., Any]], onnxscript.OnnxFunction]:
5659
"""Main decorator. Declares a function as an onnx function.
5760
5861
Args:

0 commit comments

Comments
 (0)