Tuple of strings parsed as string if one of the strings contains a hyphen
- Dominant language
- Python
- Stars
- 28.2k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
Research direction
Run the reported commands with example.py to reproduce tuple parsing for values containing hyphens and other symbols. Trace the argument-parsing entry point that handles tuples, lists, sets, and dicts, then add or update coverage for these cases. Done means hyphenated string values remain in their intended container without requiring repr-style quoting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100