Skip to content

Commit

Permalink
Fix typos in test component docstrings.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 379999792
Change-Id: I2594db4540cfe20820951bae479d16c167ba391a

adding code to support optional type appreviation request

Author:    Damien Burks <damien@damienjburks.com>

committing latest changes for supporting python 3.9+
  • Loading branch information
dbieber authored and damienjburks committed Jan 24, 2022
1 parent c1266d0 commit b1d4e45
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion fire/inspectutils.py
Expand Up @@ -23,6 +23,7 @@
import types

from fire import docstrings
from typing import get_args

import six

Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion fire/test_components.py
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions fire/test_components_py3.py
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit b1d4e45

Please sign in to comment.