Skip to content
New issue

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

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

Already on GitHub? # to your account

Incorrect type hint when @command uses a custom class #2211

Closed
matejcik opened this issue Mar 11, 2022 · 1 comment · Fixed by #2212
Closed

Incorrect type hint when @command uses a custom class #2211

matejcik opened this issue Mar 11, 2022 · 1 comment · Fixed by #2212
Milestone

Comments

@matejcik
Copy link
Contributor

The @command decorator is annotated as always returning Command.

This is a problem when supplying custom class, e.g.:

@click.command(cls=MyClass)
def foo():
     ...

reveal_type(foo)  # revealed type is `Command`
foo.my_property = 6  # error: `Command` does not have a member `my_property`

Environment:

  • Python version: any
  • Click version: 8.x
@matejcik matejcik mentioned this issue Mar 11, 2022
6 tasks
@davidism davidism added this to the 8.1.0 milestone Mar 17, 2022
@davidism
Copy link
Member

This is causing issues, please see #2227 and #2233.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants