Skip to content

Commit 107290a

Browse files
committed
fix typs.UnionType in python 3.10+
1 parent c9d1b6e commit 107290a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

function_schema/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import enum
22
import typing
3+
import types
34
import inspect
45

56

@@ -138,7 +139,7 @@ def guess_type(
138139
origin = typing.get_origin(T)
139140

140141
# hacking around typing modules, `typing.Union` and `types.UnitonType`
141-
if origin is typing.Union:
142+
if origin is typing.Union or origin is types.UnionType:
142143
union_types = [t for t in typing.get_args(T) if t is not type(None)]
143144
_types = []
144145
for union_type in union_types:

0 commit comments

Comments
 (0)