Skip to content
Myr

fix `group` overload with `cls` arg

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by layday · committed by David Lord · parent 56b15be · Browse files · 3 files+15 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−6 removed

  • tests:+11 added−0 removed
  • other:+4 added−6 removed

3 files+15 added−6 removed

modified:src/click/decorators.py+2 added-6 removed
269 unmodified lines
270 ...271272273# variant: name omitted, cls _must_ be a keyword argument, @group(cmd=GroupCls, ...)274# The _correct_ way to spell this overload is to use keyword-only argument syntax:275# def group(*, cls: t.Type[GrpType], **attrs: t.Any) -> ...276# However, mypy thinks this doesn't fit the overloaded function. Pyright does277# accept that spelling, and the following work-around makes pyright issue a278# warning that GrpType could be left unsolved, but mypy sees it as fine. *shrug*274@t.overload275def group(276 name: None = None,277 *,282 cls: t.Type[GrpType] = ...,278 cls: t.Type[GrpType],279 **attrs: t.Any,280) -> t.Callable[[_AnyCallable], GrpType]:281 ...282
279 unmodified lines
added:tests/typing/typing_group_kw_options.py+11 added
1from typing_extensions import assert_type23import click456@click.group(context_settings={})7def hello() -> None:8 pass91011assert_type(hello, click.Group)
modified:CHANGES.rst+2 added
3 unmodified lines
4-------------56Unreleased78- Fix an issue with type hints for ``@click.group()``. :issue:`2558`91011Version 8.1.512-------------1314Released 2023-07-13
1082 unmodified lines