[feature request] support multiple dialects for boolean parameters
還沒有人認領這個 Issue。
評估
研究方向
使用提供的 a.py 範例重現該行為,然後追蹤 Python Fire 的布林引數解析入口。明確如何啟用選用行為,並驗證 0、false 和 no 會變為 False,同時現有形式持續有效。
由索引模型根據 Issue 內容生成。
描述
Consider the following code:
import fire
def a(flag: bool):
if flag:
print("hooray!")
else:
print("Wanna see a flag :(")
if __name__ == '__main__': fire.Fire(a)
Now, the following options work as expected (print 'hooray!'):
python a.py --flag
python a.py --flag=True
python a.py --flag=true
However, in order to disable flag explicity the only working option is:
python a.py --flag=False
and the seemingly rational version
python a.py --flag=false
result in 'hooray' being printed as flag is parsed as a string 'false' which then casts to boolean True.
My request:
support 0, 'false' and 'no' as valid boolean arguments that all cast to False. Make this behavior optional. One way to do this is by adding a custom type to lable such flags with.
- 主要語言
- Python
- 星號
- 28.2k
- 分支
- 1.5k
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
google/python-fire 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
google/python-fire#705 ·
-
難度 2/5 1-3 小時 新手友好度 76/100
google/python-fire#703 ·
-
難度 2/5 1-3 小時 新手友好度 85/100
google/python-fire#693 ·
-
Release 0.7.2?未關閉
難度 3/5 1-2 天 新手友好度 38/100
google/python-fire#698 ·
-
難度 3/5 1-2 天 新手友好度 58/100
google/python-fire#672 · 5 則留言 ·
查看 google/python-fire 的全部 Issue
相似的 Issue
-
tool-calling
難度 2/5 1-3 小時 新手友好度 88/100
vllm-project/vllm#59838 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 92/100
raullenchai/Rapid-MLX#4042 ·
維護者通常 1 天內回覆
-
documentation
難度 1/5 1 小時以內 新手友好度 92/100
transitmatters/mbta-slow-zone-bot#70 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
litestar-org/advanced-alchemy#811 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆