From 836e7393df87e5358d197cc7698f9cb72dcfdd7f Mon Sep 17 00:00:00 2001 From: "omer.roth" Date: Wed, 18 Nov 2026 08:43:02 +0200 Subject: [PATCH] CM-78466: Upgrade click to 8.3.3 and typer to 0.25.1 click was pinned to <8.2 (resolving to 8.1.8), which is affected by CVE-2026-7246 and blocks installs in environments that require click >= 8.3.3. typer 0.15 caps click below 8.2, so it moves too. - click >=8.3.3,<8.4: 8.3.3 carries the CVE fix. 8.4+ duplicates the "Did you mean" hint with typer 0.25, which pinned click <8.4 for it. - typer >=0.25.1,<0.26: 0.26+ vendors its own Click, so it no longer renders click.ClickException and cannot mount the raw click `platform` group. Moving there is a separate migration. Behavior changes from click 8.2+: a group run with no args shows help and exits 2 instead of 0; misspelled commands get a suggestion; help no longer prints "[default: None]". Add tests for the Typer/Click seam so a future bump that breaks error rendering, the platform group or the typo hint fails CI. Co-Authored-By: Claude Opus 5.5 --- poetry.lock | 42 +++++++++++------- pyproject.toml | 4 +- tests/cli/test_click_typer_compat.py | 65 ++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 tests/cli/test_click_typer_compat.py diff --git a/poetry.lock b/poetry.lock index c39cd86b..146b680a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.4.1 and should not be changed by hand. [[package]] name = "altgraph" @@ -13,6 +13,18 @@ files = [ {file = "altgraph-0.17.5.tar.gz", hash = "sha256:c87b395dd12fabde9c99573a9749d67da8d29ef9de0125c7f536699b4a9bc9e7"}, ] +[[package]] +name = "annotated-doc" +version = "0.0.6" +description = "Document parameters, class attributes, return types, and variables inline, with Annotated." +optional = false +python-versions = ">=3.10" +groups = ["main"] +files = [ + {file = "annotated_doc-0.0.6-py3-none-any.whl", hash = "sha256:361ca0950cc7082f53fa69e9328409f40a62c61e57e0a47e1825a08078a58a53"}, + {file = "annotated_doc-0.0.6.tar.gz", hash = "sha256:7969bb69912085b2285849c0dcac0b4b374fd180c13cf10a87f284ffcf347bbf"}, +] + [[package]] name = "annotated-types" version = "0.8.0" @@ -366,14 +378,14 @@ files = [ [[package]] name = "click" -version = "8.1.8" +version = "8.3.3" description = "Composable command line interface toolkit" optional = false -python-versions = ">=3.7" +python-versions = ">=3.10" groups = ["main"] files = [ - {file = "click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2"}, - {file = "click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a"}, + {file = "click-8.3.3-py3-none-any.whl", hash = "sha256:a2bf429bb3033c89fa4936ffb35d5cb471e3719e1f3c8a7c3fff0b8314305613"}, + {file = "click-8.3.3.tar.gz", hash = "sha256:398329ad4837b2ff7cbe1dd166a4c0f8900c3ca3a218de04466f38f6497f18a2"}, ] [package.dependencies] @@ -1841,12 +1853,12 @@ version = "84.1.0" description = "Most extensible Python build backend with support for C/C++ extension modules" optional = false python-versions = ">=3.10" -groups = ["dev", "executable"] +groups = ["executable"] +markers = "python_version < \"3.15\"" files = [ {file = "setuptools-84.1.0-py3-none-any.whl", hash = "sha256:5231689c6ac8156cd155cfb98c3fd6fb252c3e7e9bd3d78b64d3c55f132624c9"}, {file = "setuptools-84.1.0.tar.gz", hash = "sha256:23657205b63d4d31395ab917815247f694aafad28cd21316bf5fd45a51048ea0"}, ] -markers = {executable = "python_version < \"3.15\""} [package.extras] check = ["pytest-checkdocs (>=2.14)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\"", "ruff (>=0.13.0) ; sys_platform != \"cygwin\""] @@ -2035,21 +2047,21 @@ files = [ [[package]] name = "typer" -version = "0.15.4" +version = "0.25.1" description = "Typer, build great CLIs. Easy to code. Based on Python type hints." optional = false -python-versions = ">=3.7" +python-versions = ">=3.10" groups = ["main"] files = [ - {file = "typer-0.15.4-py3-none-any.whl", hash = "sha256:eb0651654dcdea706780c466cf06d8f174405a659ffff8f163cfbfee98c0e173"}, - {file = "typer-0.15.4.tar.gz", hash = "sha256:89507b104f9b6a0730354f27c39fae5b63ccd0c95b1ce1f1a6ba0cfd329997c3"}, + {file = "typer-0.25.1-py3-none-any.whl", hash = "sha256:75caa44ed46a03fb2dab8808753ffacdbfea88495e74c85a28c5eefcf5f39c89"}, + {file = "typer-0.25.1.tar.gz", hash = "sha256:9616eb8853a09ffeabab1698952f33c6f29ffdbceb4eaeecf571880e8d7664cc"}, ] [package.dependencies] -click = ">=8.0.0,<8.2" -rich = ">=10.11.0" +annotated-doc = ">=0.0.2" +click = ">=8.2.1" +rich = ">=13.8.0" shellingham = ">=1.3.0" -typing-extensions = ">=3.7.4.3" [[package]] name = "typing-extensions" @@ -2133,4 +2145,4 @@ standard = ["httptools (>=0.8.0)", "python-dotenv (>=0.13)", "pyyaml (>=5.1)", " [metadata] lock-version = "2.1" python-versions = ">=3.10" -content-hash = "9302354e48512aafb400f93f77231e4b5a2ef39929f1e712f90ccb8913c56e53" +content-hash = "256e96bf429d0f1154e3eaf8ddbd3f85d4edcd9cd9188189e7e63ec155e7aa9c" diff --git a/pyproject.toml b/pyproject.toml index 1847198a..4cab39d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ requires-poetry = ">=2.0" version = "0.0.0" # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag [tool.poetry.dependencies] -click = ">=8.1.0,<8.2.0" +click = ">=8.3.3,<8.4.0" colorama = ">=0.4.3,<0.5.0" pyyaml = ">=6.0,<7.0" marshmallow = ">=4.1.2,<5.0.0" @@ -44,7 +44,7 @@ urllib3 = ">=2.8.0,<3.0.0" pyjwt = ">=2.15.0,<3.0" rich = ">=15.0.0,<16.0.0" patch-ng = "1.19.1" -typer = "^0.15.3" +typer = ">=0.25.1,<0.26.0" tenacity = ">=9.2.1,<9.3.0" mcp = ">=1.30.0,<2.0.0" truststore = ">=0.10.4,<0.11.0" diff --git a/tests/cli/test_click_typer_compat.py b/tests/cli/test_click_typer_compat.py new file mode 100644 index 00000000..ec8868fe --- /dev/null +++ b/tests/cli/test_click_typer_compat.py @@ -0,0 +1,65 @@ +"""Guards the seam between Typer and the Click APIs the CLI uses directly. + +The CLI raises ``click.ClickException``, mounts a raw ``click.Group`` (``platform``) +into the Typer app, and relies on Typer rendering both. Typer releases that vendor +their own copy of Click (0.26+) silently break these paths, so cover them end to end. +""" + +from unittest.mock import patch + +import click +from typer.testing import CliRunner + +from cycode.cli.app import app +from tests.conftest import CLI_ENV_VARS + +_BASE_ARGS = ['--no-update-notifier'] + + +def _invoke(*args: str) -> 'click.testing.Result': + return CliRunner().invoke(app, [*_BASE_ARGS, *args], env=CLI_ENV_VARS) + + +def test_click_exception_is_rendered_as_error_not_traceback() -> None: + result = _invoke('ignore') + + assert result.exit_code == 1 + assert 'Ignore by type is missing' in result.output + assert 'Traceback' not in result.output + assert isinstance(result.exception, SystemExit) + + +def _fake_platform_groups(*_: object) -> list[tuple[click.Group, str]]: + group = click.Group(name='tools', help='Fake tools group') + + @group.command(name='ping', help='Fake ping command') + def ping() -> None: + click.echo('pong') + + return [(group, 'tools')] + + +def test_platform_click_group_is_mounted_and_invocable() -> None: + with patch('cycode.cli.apps.api.api_command.build_api_command_groups', side_effect=_fake_platform_groups): + help_result = _invoke('platform', '--help') + run_result = _invoke('platform', 'tools', 'ping') + + assert help_result.exit_code == 0, help_result.output + assert 'tools' in help_result.output + + assert run_result.exit_code == 0, run_result.output + assert 'pong' in run_result.output + + +def test_misspelled_command_suggests_once() -> None: + result = _invoke('scna') + + assert result.exit_code == 2 + assert result.output.count("Did you mean 'scan'?") == 1 + + +def test_group_without_args_shows_help_with_usage_exit_code() -> None: + result = _invoke('scan') + + assert result.exit_code == 2 + assert 'Usage' in result.output