Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyright support #2566

Closed
mehdigmira opened this issue Jul 16, 2023 · 1 comment
Closed

pyright support #2566

mehdigmira opened this issue Jul 16, 2023 · 1 comment

Comments

@mehdigmira
Copy link

mehdigmira commented Jul 16, 2023

@click.group()
def cli():
  pass

with the code snippet above, pyright reports Untyped function decorator obscures type of function; ignoring decorator

The error is caused by the following overload

# variant: name omitted, cls _must_ be a keyword argument, @group(cmd=GroupCls, ...)
# The _correct_ way to spell this overload is to use keyword-only argument syntax:
# def group(*, cls: t.Type[GrpType], **attrs: t.Any) -> ...
# However, mypy thinks this doesn't fit the overloaded function. Pyright does
# accept that spelling, and the following work-around makes pyright issue a
# warning that GrpType could be left unsolved, but mypy sees it as fine. *shrug*
@t.overload
def group(
    name: None = None,
    cls: t.Type[GrpType] = ...,
    **attrs: t.Any,
) -> t.Callable[[_AnyCallable], GrpType]:
    ...

The comment suggests the author is aware of the issue ? Is there some way this could be fixed ?
This makes 8.1.5 version nearly unusable for codebases relying on pyright as a typechecker

Environment:

  • Python version: 3.11
  • Click version: 8.1.5
@davidism
Copy link
Member

Duplicate of #2565

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants