google / google/python-fire

Optional type args are mistyped in help

未關閉
#508 5 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Python
星號
28.2k
分支
1.5k
PR 合併指標
30 天內沒有已合併 PR

描述

Type annotations that use `typing.Optional` are incorrectly documented when showing help.

## Example 1

```python
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

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

```python
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

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.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。