diff --git a/fire/inspectutils.py b/fire/inspectutils.py index 0fa8e7d3..ca35bc12 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,6 @@ 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 +165,13 @@ def Py3GetFullArgSpec(fn): varkw = name if param.annotation is not param.empty: annotations[name] = param.annotation + if "Optional" in str(annotations[name]) or "Union" in str(annotations[name]): + tuple_param1 = get_args(annotations[name])[0].__name__ + tuple_param2 = get_args(annotations[name])[1].__name__ + if str(tuple_param2) != "NoneType": + annotations[name] = tuple_param1 + ", " + tuple_param2 + else: + annotations[name] = tuple_param # pylint: enable=protected-access if not kwdefaults: diff --git a/fire/test_components.py b/fire/test_components.py index eee9a07c..027a6b19 100644 --- a/fire/test_components.py +++ b/fire/test_components.py @@ -98,7 +98,7 @@ def double(self, count=0): count: Input number that you want to double. Returns: - A number that is the double of count.s + A number that is the double of count. """ return 2 * count diff --git a/fire/test_components_py3.py b/fire/test_components_py3.py index 3c21f4ba..b6c78c84 100644 --- a/fire/test_components_py3.py +++ b/fire/test_components_py3.py @@ -67,7 +67,7 @@ def double(self, count: float) -> float: count: Input number that you want to double. Returns: - A number that is the double of count.s + A number that is the double of count. """ return 2 * count @@ -89,7 +89,7 @@ def double(self, count: float = 0) -> float: count: Input number that you want to double. Returns: - A number that is the double of count.s + A number that is the double of count. """ return 2 * count