Fix mypy errors from deprecated click.MultiCommand isinstance check#203
Fix mypy errors from deprecated click.MultiCommand isinstance check#203adamtheturtle wants to merge 1 commit into
Conversation
Fixes janluke#202. `click.MultiCommand` is deprecated since Click 8 and is no longer usable as the second argument to `isinstance` at the type level, which caused `mypy cloup` to fail with two errors on master. `click.Group` exposes `format_commands` on both Click 8.3 and 8.4, so the behavior is unchanged. This also silences the runtime DeprecationWarning emitted when calling `format_help` on a group. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This change would break compatibility with click 8.1. Think of a user on click 8.1 who still uses a Easiest way is to require click >= 8.2. In that case, everything's fine because So I will do this instead:
Closing this PR, as I'll apply the above changes instead. But thank you very much for this! |
|
Thank you! |
Fixes #202.
click.MultiCommandis deprecated since Click 8 and is no longer usable as the second argument toisinstanceat the type level, causingmypy cloupto fail onmasterwith two errors incloup/_commands.py.click.Groupexposesformat_commandson every supported Click version (>= 8.0), so the behavior at runtime is unchanged. This also silences theDeprecationWarningemitted whenformat_helpis called on a group.In practice, the only
MultiCommandcloup ever produces iscloup.Group(which subclassesclick.Group), so the original check was already effectively a Group check.Test plan
Tested across the full supported Click range (
>= 8.0, < 9.0), Python 3.12, mypy 2.1.0:_params.pyi(fixed by #201)The Click 8.0 issues reproduce on
masterwithout this change and are unrelated:cloup/types.pypassesexecutable=...toclick.Path, a kwarg added in a later Click 8.x# type: ignorecomments on@overloaddecorators (lines 273, 350) become unused because the underlying mypy warning doesn't fire against Click 8.0's older stubs🤖 Generated with Claude Code