String hinted arguments passed numerical values should not be coerced
まだ誰も着手していません。
評価
調査の方向性
issue には tp.py の最小限の再現例がありますが、プロジェクトのファイルやテストは挙げられていません。まず Fire が CLI の値をどのように解析し、callable の引数に型ヒントを適用するかを追い、その後、string 型ヒント付き引数に関する該当テストを探してください。1.10 と '1.10' の両方が文字列として関数に渡され、この動作を網羅する回帰テストが追加されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Observed behavior
If a callable command function defines an argument with a string hint, e.g. arg: str, and a value of 1.10 is passed to it, then it receives an argument of type float with value 1.1 which has different meaning than the passed value.
This is particularly troublesome when dealing with versions since 1.1 is much different than 1.10.
Expected behavior
Fire should not coerce the value to a type different than the type hint, regardless of its format.
Reproduction
Code
# tp.py
import fire
def main(arg: str):
print(f"Hello! {type(arg)} {arg}")
if __name__ == "__main__":
fire.Fire(main)
Execution
$ python tp.py 1.10
Hello! <class 'float'> 1.1
or
$ python tp.py '1.10'
Hello! <class 'float'> 1.1
Metadata
fire version v0.7.1
- 主要言語
- Python
- スター
- 28.2k
- フォーク
- 1.5k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/python-fire のほかの issue
-
External pager resets custom SIGINT handlers to SIG_DFL対応中かも @hugosmoreira が 14 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
google/python-fire#723 · コメント 1 件 ·
-
EllipsisMiddleTruncate exceeds requested width when only the ellipsis fits対応中かも @hugosmoreira が 14 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
google/python-fire#722 · コメント 1 件 ·
-
Windows ANSI initialization uses nonexistent subprocess.STD_OUTPUT_HANDLE対応中かも @Fire162 が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
google/python-fire#721 · コメント 1 件 ·
-
Setup docs still say `python setup.py install`, but `setup.py` was removed対応中かも @GreedyC が 18 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 93/100
google/python-fire#718 · コメント 1 件 ·
-
Calling an async command from an active event loop raises RuntimeError and leaves an unawaited coroutine対応中かも @aashish254 が 20 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google/python-fire#716 ·
google/python-fire の issue をすべて見る
似ている issue
-
`destroy` sans terminal répond « Aborted. » au lieu de réclamer `--yes` comme `clean` et `reset`オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
stephrobert/dsoxlab#354 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
jasonacox/pypowerwall#472 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: DoubleMLRDDData accepts a score_col that is no data column (as in its docstring example); the running variable then becomes a covariate and RDFlex fails対応中かも @vrjdev が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
DoubleML/doubleml-for-py#455 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Python mod.Box[T] annotation gets a false generic_arg edge that replaces the parameter_type one ('is' on tree-sitter nodes)対応中かも @rohit-jsfreaky が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Graphify-Labs/graphify#5110 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
assafelovic/gpt-researcher#2277 ·
メンテナーはふだん 10 日以内に返信