click
click copied to clipboard
Click shell completion can trigger parameter callbacks unexpectedly
Description
Shell completion can execute parameter callbacks while Click is only trying to determine completion information.
This can cause application code to run during tab completion even though the command has not been invoked.
Minimal reproduction
import click
def callback(ctx, param, value):
print("CALLBACK EXECUTED", file=__import__("sys").stderr)
return value
@click.command()
@click.option("--name", callback=callback)
def cli(name):
click.echo(name)
if __name__ == "__main__":
cli()