Optional type args are mistyped in help
Opened this issue · 3 comments
impredicative commented
Type annotations that use typing.Optional
are incorrectly documented when showing help.
Example 1
from typing import Optional
import fire
def main(arg: Optional[str] = 'something'):
"""Do something with arg."""
if __name__ == '__main__':
fire.Fire(main)
The corresponding help output is:
INFO: Showing help with the command 'firetest.py -- --help'.
NAME
firetest.py - Do something with arg.
SYNOPSIS
firetest.py <flags>
DESCRIPTION
Do something with arg.
FLAGS
-a, --arg=ARG
Type: Optional
Default: 'something'
Here, Type: Optional
is totally incorrect. It should be Optional[str]
. My use of str
is just an example and it can be anything.
Example 2
from typing import Optional
import fire
def main(arg: Optional[str] = None):
"""Do something with arg."""
if __name__ == '__main__':
fire.Fire(main)
The corresponding help output is:
INFO: Showing help with the command 'firetest.py -- --help'.
NAME
firetest.py - Do something with arg.
SYNOPSIS
firetest.py <flags>
DESCRIPTION
Do something with arg.
FLAGS
-a, --arg=ARG
Type: Optional[Optional]
Default: None
Here, Type: Optional[Optional]
is even more incorrect. It should be Optional[str]
. My use of str
is just an example and it can be anything.
dbieber commented
Thanks for reporting this. Looks like a bug to me. Next steps are to add a test case and identify and resolve the issue.
Jemeljanov commented
Jemeljanov commented