diff --git a/fire/inspectutils.py b/fire/inspectutils.py index 0fa8e7d3..268150ec 100644 --- a/fire/inspectutils.py +++ b/fire/inspectutils.py @@ -23,6 +23,7 @@ import types from fire import docstrings +from typing import get_args import six @@ -143,7 +144,7 @@ def Py3GetFullArgSpec(fn): if sig.return_annotation is not sig.empty: annotations['return'] = sig.return_annotation - + for param in sig.parameters.values(): kind = param.kind name = param.name @@ -165,6 +166,10 @@ def Py3GetFullArgSpec(fn): varkw = name if param.annotation is not param.empty: annotations[name] = param.annotation + if "Union" in str(annotations[name]): + union_type_tuple = get_args(annotations[name]) + annotations[name] = union_type_tuple[0] + # pylint: enable=protected-access if not kwdefaults: