google / google/python-fire

Raising FireError in __init__ is not handled properly

未关闭
#250 4 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
28.2k
派生
1.5k
PR 合并指标
30 天内没有已合并 PR

描述

In version 0.3.1 when user attempts to raise error in the `__init__` method the effective error that gets printed is about missing `self` argument. Minimal example:
```
import fire
from fire.core import FireError
class Calc:

def __init__(self):
raise FireError('foo')

def add(self):
pass

if __name__ == "__main__":
fire.Fire(Calc)
```

```
python calc.py add
ERROR: The function received no value for the required argument: self
```

When executed interactively, the error is correct:
```
>>>import calc; import fire
>>>fire.Fire(calc.Calc)
ERROR: foo
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。