Skip to content

Commit e6b2d8e

Browse files
committed
committing latest changes for supporting python 3.9+
1 parent 7eb9a9e commit e6b2d8e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

fire/inspectutils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def Py3GetFullArgSpec(fn):
144144

145145
if sig.return_annotation is not sig.empty:
146146
annotations['return'] = sig.return_annotation
147-
148147
for param in sig.parameters.values():
149148
kind = param.kind
150149
name = param.name
@@ -166,10 +165,13 @@ def Py3GetFullArgSpec(fn):
166165
varkw = name
167166
if param.annotation is not param.empty:
168167
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-
168+
if "Optional" in str(annotations[name]) or "Union" in str(annotations[name]):
169+
tuple_param1 = get_args(annotations[name])[0].__name__
170+
tuple_param2 = get_args(annotations[name])[1].__name__
171+
if str(tuple_param2) != "NoneType":
172+
annotations[name] = tuple_param1 + ", " + tuple_param2
173+
else:
174+
annotations[name] = tuple_param
173175
# pylint: enable=protected-access
174176

175177
if not kwdefaults:

0 commit comments

Comments
 (0)