Skip to content

Error when updating click from 8.2.1 to 8.3.0

ERROR DESCRIPTION

While co-developing mednet following the development guide available in the medai group, I encountered the following error when running the training script (mednet/scripts/train.py):

TypeError: Secondary flag is not valid for non-boolean flag.

referred to line 251 of mednet/scripts/train.py:

@click.option(
        "--balance-classes/--no-balance-classes",
        "-B/-N",
        help=rewrap(
            """If set, balances the loss term to take into consideration the occurence
            of each target in the training and validation splits."""
        ),
        required=True,
        show_default=True,
        default=True,
        cls=ResourceOption,
    )

CONTEXT

To co-develop mednet, I copied its dependencies directly into my project’s pixi.toml. In the current version of mednet, the click dependency is not pinned — the pixi.lock file resolves click to version 8.2.1, which works correctly.

However, when installing dependencies in my own Pixi environment, since no explicit version pin exists for click, the latest release (8.3.0) was automatically downloaded and installed.

ISSUE

With click 8.3.0, the command that previously worked under 8.2.1 now fails with the error above. The issue appears to stem from the recent changes to flag option handling introduced with the latest version of click.