Skip to content

Commit 13f52fe

Browse files
author
Damien Burks
committed
adding code to support optional type appreviation request
1 parent ed44d8b commit 13f52fe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fire/inspectutils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import types
2424

2525
from fire import docstrings
26+
from typing import get_args
2627

2728
import six
2829

@@ -143,7 +144,7 @@ def Py3GetFullArgSpec(fn):
143144

144145
if sig.return_annotation is not sig.empty:
145146
annotations['return'] = sig.return_annotation
146-
147+
147148
for param in sig.parameters.values():
148149
kind = param.kind
149150
name = param.name
@@ -165,6 +166,10 @@ def Py3GetFullArgSpec(fn):
165166
varkw = name
166167
if param.annotation is not param.empty:
167168
annotations[name] = param.annotation
169+
if "Union" in str(annotations[name]):
170+
union_type_tuple = get_args(annotations[name])
171+
annotations[name] = union_type_tuple[0]
172+
168173
# pylint: enable=protected-access
169174

170175
if not kwdefaults:

0 commit comments

Comments
 (0)