google / google/python-fire

Only plain literals should be parsed

Đang mở
#97 9 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug help wanted
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ả

@dbieber correctly pointed out in #95 that there is a more general problem with the parsing code. This is a follow up issue to that issue which only dealt with the most common case of a single argument.

Here are some cases demonstrating
```bash
$ python3 -c "import fire.parser as p; v = p.DefaultParseValue('[1+1]'); print(type(v), v)"
[2]
$ python3 -c "import fire.parser as p; v = p.DefaultParseValue('{key: 1+1}'); print(type(v), v)"
{'key': 2}
```

Some options are:
1. Accept the existing behaviour.
2. Always parse the whole argument as a string by doing `raise ValueError` in ``fire.parser._LiteralEval`
3. Parse only the sub expressions as strings

For 2. and 3. I think these would be the valid types from the `ast` module.

- `Str`
- `Name` (converted to `Str`)
- `Num`
- `List`
- `Tuple`
- `Dict`
- `Set`
- `UnaryOp`

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.