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

Cannot use parameterless command decorator with custom command_class #2416

Closed
ewilliamson-patreon opened this issue Dec 15, 2022 · 0 comments
Milestone

Comments

@ewilliamson-patreon
Copy link
Contributor

Click throws an assertion error if you try to use the parameterless command decorator on a group with a command_class defined. The error is due to the command_class being added to kwargs before the assertion for no kwargs.

minimal repro

import click

class CustomCommand(click.Command):
    pass

class CustomGroup(click.Group):
    command_class = CustomCommand

@click.group(cls=CustomGroup)
def grp():
    pass

@grp.command
def cli():
    click.echo("hello custom command class")

error

ewilliamson@ip-192-168-50-39 ~ % python minimal_repro.py
Traceback (most recent call last):
  File "/Users/ewilliamson/minimal_repro.py", line 14, in <module>
    def cli():
  File "/Users/ewilliamson/.pyenv/versions/3.10.7/lib/python3.10/site-packages/click/core.py", line 1847, in command
    assert (
AssertionError: Use 'command(**kwargs)(callable)' to provide arguments.

expected

The @grp.command would be successfully parsed the same as without using CustomGroup

Environment:

  • Python version: Python 3.10.7
  • Click version: click==8.1.3
@davidism davidism added this to the 8.1.4 milestone Jun 30, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 15, 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