tensorneko-util 0.3.22__py3-none-any.whl → 0.3.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tensorneko_util/util/dispatcher.py +17 -2
- tensorneko_util/version.txt +1 -1
- tensorneko_util/visualization/watcher/web/dist/assets/{index.5195781e.js → index.f19b5d1c.js} +34 -34
- tensorneko_util/visualization/watcher/web/dist/index.html +1 -1
- {tensorneko_util-0.3.22.dist-info → tensorneko_util-0.3.23.dist-info}/METADATA +2 -1
- {tensorneko_util-0.3.22.dist-info → tensorneko_util-0.3.23.dist-info}/RECORD +9 -9
- {tensorneko_util-0.3.22.dist-info → tensorneko_util-0.3.23.dist-info}/WHEEL +0 -0
- {tensorneko_util-0.3.22.dist-info → tensorneko_util-0.3.23.dist-info}/licenses/LICENSE +0 -0
- {tensorneko_util-0.3.22.dist-info → tensorneko_util-0.3.23.dist-info}/top_level.txt +0 -0
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import inspect
|
|
4
|
+
import sys
|
|
4
5
|
import warnings
|
|
5
6
|
from typing import Callable, Dict, List, Generic, Sequence, Optional, TYPE_CHECKING, overload
|
|
6
7
|
|
|
7
8
|
from .type import T
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
def _is_union_type(annotation) -> bool:
|
|
12
|
+
"""
|
|
13
|
+
Check if the annotation is a Union type.
|
|
14
|
+
Compatible with Python 3.8 ~ 3.14+
|
|
15
|
+
"""
|
|
16
|
+
if sys.version_info >= (3, 14):
|
|
17
|
+
# Python 3.14+: str(Union[int, str]) returns "int | str"
|
|
18
|
+
# Use typing.get_origin() for reliable detection
|
|
19
|
+
from typing import Union, get_origin
|
|
20
|
+
return get_origin(annotation) is Union
|
|
21
|
+
else:
|
|
22
|
+
# Python < 3.14: str(Union[int, str]) returns "typing.Union[int, str]"
|
|
23
|
+
return str(annotation)[:13] == "typing.Union["
|
|
24
|
+
|
|
25
|
+
|
|
10
26
|
class DispatcherTypeWarning(Warning):
|
|
11
27
|
pass
|
|
12
28
|
|
|
@@ -38,8 +54,7 @@ class Dispatcher:
|
|
|
38
54
|
possible_types = [[]]
|
|
39
55
|
|
|
40
56
|
for param in parameters:
|
|
41
|
-
|
|
42
|
-
is_union = str(param.annotation)[:13] == "typing.Union["
|
|
57
|
+
is_union = _is_union_type(param.annotation)
|
|
43
58
|
|
|
44
59
|
# if no default value and not union, just append to each possible types
|
|
45
60
|
if param.default is inspect.Signature.empty and not is_union:
|
tensorneko_util/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.23
|