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

Invoking a command does not fail on missing arguments #2801

Open
oeko2002 opened this issue Nov 7, 2024 · 0 comments
Open

Invoking a command does not fail on missing arguments #2801

oeko2002 opened this issue Nov 7, 2024 · 0 comments

Comments

@oeko2002
Copy link

oeko2002 commented Nov 7, 2024

If I invoke a command with an required argument (nargs=1) from within another one without passing the argument it still works.
None is passed as default, although I do no set some.
If I invoke the callback I get the expected exception.

Short example

import click

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

@group.command()
@click.argument("arg", nargs=1, required=True)
def withparam(arg):
    print(
        f"INVOKED with argument {arg}"
    )

@group.command()
def withoutparam():
    print(f"RUNNING without params")
    click.get_current_context().invoke(withparam)

if __name__ == "__main__":
    group()

Result is:

> python test.py withoutparam
RUNNING without params
INVOKED with argument None

Is this intended?

Environment:

  • Python version: 3.13
  • Click version: 8.1.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant