Skip to content

Commit b1d4e45

Browse files
dbieberdamienjburks
authored andcommitted
Fix typos in test component docstrings.
PiperOrigin-RevId: 379999792 Change-Id: I2594db4540cfe20820951bae479d16c167ba391a adding code to support optional type appreviation request Author: Damien Burks <[email protected]> committing latest changes for supporting python 3.9+
1 parent c1266d0 commit b1d4e45

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

fire/inspectutils.py

Lines changed: 8 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,6 @@ def Py3GetFullArgSpec(fn):
143144

144145
if sig.return_annotation is not sig.empty:
145146
annotations['return'] = sig.return_annotation
146-
147147
for param in sig.parameters.values():
148148
kind = param.kind
149149
name = param.name
@@ -165,6 +165,13 @@ def Py3GetFullArgSpec(fn):
165165
varkw = name
166166
if param.annotation is not param.empty:
167167
annotations[name] = param.annotation
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
168175
# pylint: enable=protected-access
169176

170177
if not kwdefaults:

fire/test_components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def double(self, count=0):
9898
count: Input number that you want to double.
9999
100100
Returns:
101-
A number that is the double of count.s
101+
A number that is the double of count.
102102
"""
103103
return 2 * count
104104

fire/test_components_py3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def double(self, count: float) -> float:
6767
count: Input number that you want to double.
6868
6969
Returns:
70-
A number that is the double of count.s
70+
A number that is the double of count.
7171
"""
7272
return 2 * count
7373

@@ -89,7 +89,7 @@ def double(self, count: float = 0) -> float:
8989
count: Input number that you want to double.
9090
9191
Returns:
92-
A number that is the double of count.s
92+
A number that is the double of count.
9393
"""
9494
return 2 * count
9595

0 commit comments

Comments
 (0)