google / google/python-fire

Type information should be visible in help screen

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

描述

Function signatures containing typing information should also show this in the help screen. For instance, I would expect the `--help` screen for `def main(arg1: str, arg2=False):` to indicate arg1 is a string type and arg2 is a bool type with default false.

I think the easiest way to make this happen is to:
- _Always_ use type information when available (even if it contradicts the default argument, since this is a developer issue -- not worth hashing out in `fire`).

However, a common programming paradigm is to write something like the following:
```python
def main(arg1: List[str] = None):
if arg1 is None:
arg1 = ['hi', 'there']
```
You can probably follow Pycharm's flow, where they redefine arg1 as Optional[List[str]]. I think this is the only valid case where the provided default doesn't match the type hint.

- Use the type of the default argument if no type information is given
- Provide no type information if both the above are missing.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

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

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