Skip to content

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

@matejcik

Description

@matejcik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions