Click 8.5.0: omitted boolean flags incorrectly trigger conflicting_options validation
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 66/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 4
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aboutcode-org/commoncode
-
Consider that Resource.parent can be None when removing resources from the codebasePossibly taken @Mirochill claimed this 177 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
aboutcode-org/commoncode#84 ·
-
Revisit cliutils.pyOpen
Difficulty 4/5 3-5 days Newbie friendliness 35/100
aboutcode-org/commoncode#102 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
aboutcode-org/commoncode#101 · 1 comment ·
-
mass-scan: Create library to collect a whole project version from Software HeritageMay be free again @chinyeungli claimed this 264 days ago, and no pull request is open. Open
aboutcode-org/commoncode#77 · 7 comments · 1 assignee ·
-
Fix DeprecationWarning in timeutils.py and archive.pyPossibly taken @shashank-tomar0 claimed this 10 days ago. Opengood first issue
Difficulty 3/5 1-2 days Newbie friendliness 42/100
aboutcode-org/commoncode#75 · 1 comment ·
All issues in aboutcode-org/commoncode
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mohanraj00/entelos#200 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
sweep
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
bketelsen/truenas-mcp#77 ·
Maintainers usually reply within 1 day
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskOpen
Difficulty 1/5 Under an hour Newbie friendliness 86/100
sandbox-quantum/switch#2163 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
openedx/xblock-lti-consumer#765 ·
Maintainers usually reply within 1 day