Commit 8f71f1a
authored
This pull request introduces type parameterization using `TypeVar` and
`ParamSpec` to enhance type safety and flexibility in the `onnxscript`
module.
### Type Parameterization Enhancements:
*
[`onnxscript/main.py`](diffhunk://#diff-1f9f494aa46ce42a47c4191deb91aaded1b216b24accc43685561281507e7ca8L9-R20):
Introduced `_R` and `_P` type variables, and updated the `script`
decorator and `transform` function signatures to use `Callable[_P, _R]`
for better type inference.
[[1]](diffhunk://#diff-1f9f494aa46ce42a47c4191deb91aaded1b216b24accc43685561281507e7ca8L9-R20)
[[2]](diffhunk://#diff-1f9f494aa46ce42a47c4191deb91aaded1b216b24accc43685561281507e7ca8L42-R46)
[[3]](diffhunk://#diff-1f9f494aa46ce42a47c4191deb91aaded1b216b24accc43685561281507e7ca8L78-R82)
*
[`onnxscript/values.py`](diffhunk://#diff-9625fb4ad20b7aa13388f751c0fde3a809f2b6c91023413a02ea2249f9071248R16-R36):
Added `Generic`, `TypeVar`, and `ParamSpec` imports, and updated the
`OnnxFunction` class to inherit from `Generic[_P, _R]`. Modified the
`__call__` method to use `_P.args` and `_P.kwargs` for improved type
checking.
[[1]](diffhunk://#diff-9625fb4ad20b7aa13388f751c0fde3a809f2b6c91023413a02ea2249f9071248R16-R36)
[[2]](diffhunk://#diff-9625fb4ad20b7aa13388f751c0fde3a809f2b6c91023413a02ea2249f9071248L467-R474)
[[3]](diffhunk://#diff-9625fb4ad20b7aa13388f751c0fde3a809f2b6c91023413a02ea2249f9071248L569-R581)
1 parent 634148e commit 8f71f1a
2 files changed
Lines changed: 17 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
42 | | - | |
| 46 | + | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
| |||
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
78 | | - | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
30 | 37 | | |
31 | 38 | | |
32 | 39 | | |
| |||
464 | 471 | | |
465 | 472 | | |
466 | 473 | | |
467 | | - | |
| 474 | + | |
468 | 475 | | |
469 | 476 | | |
470 | 477 | | |
| |||
566 | 573 | | |
567 | 574 | | |
568 | 575 | | |
569 | | - | |
| 576 | + | |
570 | 577 | | |
571 | 578 | | |
572 | 579 | | |
573 | 580 | | |
574 | | - | |
| 581 | + | |
575 | 582 | | |
576 | 583 | | |
577 | 584 | | |
| |||
0 commit comments