google / google/python-fire

Only plain literals should be parsed

オープン
#97 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug help wanted
主要言語
Python
スター
28.2k
フォーク
1.5k
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。