Skip to content

Make 'no such option' assertion tolerant of newer click error format#5009

Open
GuillemSeCa wants to merge 1 commit into
aboutcode-org:developfrom
GuillemSeCa:fix/click-error-message-format
Open

Make 'no such option' assertion tolerant of newer click error format#5009
GuillemSeCa wants to merge 1 commit into
aboutcode-org:developfrom
GuillemSeCa:fix/click-error-message-format

Conversation

@GuillemSeCa
Copy link
Copy Markdown

Fixes the *_latest_from_pip CI matrix (ubuntu22/24, macos14, win2019/2022) which currently fails on develop because click 8.2 changed the unknown-option error message format:

  • click < 8.2: Error: No such option: --foo
  • click >= 8.2: Error: No such option '--foo'. (Did you mean ...)

The test now asserts the stable substrings (no such option, --json--info) instead of the exact phrasing, so it works with both versions.

Verified locally: passes with click 8.3.1.

click >= 8.2 changed the unknown-option error message from
  'Error: No such option: --foo'
to
  'Error: No such option '--foo'. (Did you mean ...)'

This broke tests/scancode/test_cli.py::test_scan_errors_out_with_unknown_option
on the *_latest_from_pip CI matrix (ubuntu22/24, macos14, win2019/2022).

Relax the assertion to check for the stable substrings ('no such option'
and the offending option name) instead of the exact phrasing, so the
test works with both click < 8.2 and click >= 8.2.

Signed-off-by: Guillem Serra Cazorla <guillem@meta.com>
@GuillemSeCa
Copy link
Copy Markdown
Author

I saw the CI was slow so I also made this optional PR to speed it up 1 order of magnitude: #5013

@GuillemSeCa GuillemSeCa marked this pull request as ready for review May 18, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant