Click 8.5.0: omitted boolean flags incorrectly trigger conflicting_options validation

Open
#112 0 comments 0 reactions 0 assignees View on GitHub

@nicu1989 is already working on this.

Since Nov 13, 2026.

  • #113 by @nicu1989 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

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:

  1. 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()
  1. Use packages: python -m pip install commoncode==33.0.0 click==8.5.0
  2. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aboutcode-org/commoncode

All issues in aboutcode-org/commoncode

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.