Skip to content

Commit 3a17c85

Browse files
committed
Add support for PEP568 (fixes #15)
1 parent 46303ab commit 3a17c85

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

function_schema/core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Union,
1010
get_args,
1111
get_origin,
12+
get_type_hints,
1213
)
1314

1415
from .types import FunctionSchema, Doc
@@ -81,9 +82,11 @@ def get_function_schema(
8182
"properties": {},
8283
"required": [],
8384
}
85+
type_hints = get_type_hints(func, include_extras=True)
8486
for name, param in params.items():
85-
param_args = get_args(param.annotation)
86-
is_annotated = get_origin(param.annotation) is Annotated
87+
type_hint = type_hints[name]
88+
param_args = get_args(type_hint)
89+
is_annotated = get_origin(type_hint) is Annotated
8790

8891
enum_ = None
8992
default_value = inspect._empty

0 commit comments

Comments
 (0)