google / google/python-fire

Tuple of strings parsed as string if one of the strings contains a hyphen

Đang mở
#561 5 bình luận 1 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ả

When parsing in a tuple of strings i can normally pass in comma-separated values with no issues, however if one of the values contains a hyphen the arguments gets parsed as a string instead of a tuple of strings.

Using your provided **example.py** script
```python
import fire
fire.Fire(lambda obj: type(obj).__name__)
```

If i call it with multiple strings not containing hyphens i get the expected output
```repr
>>> python example.py '(foobar,baz)'
tuple
```
however, if I call it with a string containing a hyphen (`-`), I get this unexpected output
```repr
>>> python example.py '(foo-bar,baz)'
str
```

Is this to be expected? I also see that this is an issue with other symbols aswell.
Is there a way to work around this other than to pass in a repr-like string?

E.g, this works, but is not very human friendly:
```repr
>>> python example.py '("foo-bar","baz")'
tuple
```

Edit: This is also the case for lists, sets and dicts containing strings.

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.