Skip to content

TypeError: Secondary flag is not valid for non-boolean flag (typer 0.12 incompatible with click >= 8.2) #369

Description

@aculich

Bug description

With a fresh install of gcop, every command crashes immediately while typer builds the CLI:

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

Traceback ends in:

typer/main.py:900 in get_click_param
typer/core.py:427 in __init__
click/core.py:2942 in __init__
TypeError: Secondary flag is not valid for non-boolean flag.

Root cause

pyproject.toml pins typer = "^0.12.3" but allows click = "^8.1.7", which permits click 8.2+. Click 8.2 changed flag option validation, and typer < 0.16 passes secondary flag names in a form that click >= 8.2 rejects. Any fresh dependency resolution today picks up click 8.4.x and the CLI is unusable.

Existing installs with an older click in their environment are unaffected, which is why this only shows up on new installs or venv rebuilds.

Reproduction

pipx install gcop   # resolves click 8.4.x today
gcop --help         # TypeError: Secondary flag is not valid for non-boolean flag.

Downgrading click in the venv confirms the diagnosis:

pipx runpip gcop install 'click<8.2'
gcop --help         # works

Suggested fix

Either cap click below 8.2 (click = ">=8.1.7,<8.2"), or upgrade the typer dependency to >= 0.16 which supports the new click behavior. The cap is the minimal low-risk change; I will submit a PR.

Related: #367

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions