google / google/python-fire

Raising FireError in __init__ is not handled properly

Đang mở
#250 4 bình luận 3 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
28.2k
Fork
1.5k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.