Click 8.5.0: omitted boolean flags incorrectly trigger conflicting_options validation
評估
研究方向
The bug is in validate_option_dependencies() and PluggableCommandLineOption in the commoncode cliutils module, which decide whether an option counts as used. Run the reproduction script from the issue with click 8.5.0 and again with 8.4.2 to compare. Find how the check tells a supplied flag from a default, since click 8.5.0 seems to report omitted flags differently. Done when the script prints OK on click 8.5.0 and a regression test covers omitted boolean flags.
由索引模型根據 Issue 內容生成。
描述
With commoncode 33.0.0 and click 8.5.0, validate_option_dependencies() incorrectly reports a conflict between mutually exclusive boolean flags when neither flag is supplied:
Error: The option --strip-root cannot be used together with the --full-root option(s) and --full-root is used. You can set only one of these options at a time.
This breaks scancode 32.4.1 with conflict between --strip-root and --full-root. The problem reproduces using commoncode alone as well.
Tested with Python 3.12. CommonCode 32.4.2 is also affected. The same checks pass with Click 8.4.2.
How to standalone reproduce the error:
- Create
test.py:
import click
from commoncode import cliutils
@click.command()
@click.option(
"--strip-root", is_flag=True,
cls=cliutils.PluggableCommandLineOption,
conflicting_options=["full_root"],
)
@click.option(
"--full-root", is_flag=True,
cls=cliutils.PluggableCommandLineOption,
conflicting_options=["strip_root"],
)
@click.pass_context
def cli(ctx, strip_root, full_root):
cliutils.validate_option_dependencies(ctx)
click.echo("OK")
if __name__ == "__main__":
cli()
- Use packages:
python -m pip install commoncode==33.0.0 click==8.5.0 - Run:
python test.py-> expected output: OK, actual:Error: The option --strip-root cannot be used together with the --full-root option(s) and --full-root is used. You can set only one of these options at a time.
With click 8.4.2 the out put is OK.
- 主要語言
- Python
- 星號
- 4
- 分支
- 25
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
aboutcode-org/commoncode 的其他 Issue
-
Consider that Resource.parent can be None when removing resources from the codebase可能已有人在做 @Mirochill 於 177 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 62/100
aboutcode-org/commoncode#84 ·
-
難度 4/5 3-5 天 新手友好度 35/100
aboutcode-org/commoncode#102 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 45/100
aboutcode-org/commoncode#101 · 1 則留言 ·
-
mass-scan: Create library to collect a whole project version from Software Heritage可能重新可做 @chinyeungli 於 264 天前認領,目前沒有進行中的 PR。 未關閉
aboutcode-org/commoncode#77 · 7 則留言 · 已指派 1 人 ·
-
Fix DeprecationWarning in timeutils.py and archive.py可能已有人在做 @shashank-tomar0 於 10 天前認領。 未關閉good first issue
難度 3/5 1-2 天 新手友好度 42/100
aboutcode-org/commoncode#75 · 1 則留言 ·
查看 aboutcode-org/commoncode 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
mohanraj00/entelos#200 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 68/100
-
sweep
難度 2/5 1-3 小時 新手友好度 85/100
bketelsen/truenas-mcp#77 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 86/100
sandbox-quantum/switch#2163 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 74/100
openedx/xblock-lti-consumer#765 ·
維護者通常 1 天內回覆