File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 11import enum
22import typing
3- import types
43import inspect
4+ import platform
5+ import packaging .version
6+
7+ current_version = packaging .version .parse (platform .python_version ())
8+ py_310 = packaging .version .parse ("3.10" )
9+
10+ if current_version >= py_310 :
11+ import types
12+ from types import UnionType
13+ else :
14+ UnionType = typing .Union # type: ignore
515
616
717def get_function_schema (
@@ -139,7 +149,7 @@ def guess_type(
139149 origin = typing .get_origin (T )
140150
141151 # hacking around typing modules, `typing.Union` and `types.UnitonType`
142- if origin is typing .Union or origin is types . UnionType :
152+ if origin is typing .Union or origin is UnionType :
143153 union_types = [t for t in typing .get_args (T ) if t is not type (None )]
144154 _types = []
145155 for union_type in union_types :
You can’t perform that action at this time.
0 commit comments