Click 8.5.0: omitted boolean flags incorrectly trigger conflicting_options validation

Aberta
#112 0 comentários 0 reações 0 responsáveis Ver no GitHub

@nicu1989 já está trabalhando nisso.

Desde 13/11/2026.

  • #113 de @nicu1989 — aberto

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
66/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
cli

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
4
Forks
25
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de aboutcode-org/commoncode

Todas as issues de aboutcode-org/commoncode

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.