google / google/python-fire

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

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

描述

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.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

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

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