Correct me if I'm wrong, but it seem that click decorators obscure the function default and construction. Call the wrapped from from the REPL does not immediately work in the same way as the REPL. For example see this from dask distributed:
@click.option('--bokeh-prefix', type=str, default=None,
help="Prefix for the bokeh app")
@click.option('--preload', type=str, multiple=True, is_eager=True,
help='Module that should be loaded by each worker process '
'like "foo.bar" or "/path/to/foo.py"')
@click.argument('preload_argv', nargs=-1,
type=click.UNPROCESSED, callback=validate_preload_argv)
def main(scheduler, host, worker_port, listen_address, contact_address,
nanny_port, nthreads, nprocs, nanny, name,
memory_limit, pid_file, reconnect, resources, bokeh,
bokeh_port, local_directory, scheduler_file, interface,
death_timeout, preload, preload_argv, bokeh_prefix, tls_ca_file,
tls_cert, tls_key):
Is there some simple pattern to get at the function and all its defaults?
As far as I can surmise the only alternatives, from this issue, are to
Call the underlying function like main.callback(*args). Then you're missing default arguments from the click interface.
To use the click testing interface via something like click.testing.CliRunner().invoke(main, ['--host', '127.0.0.1'], catch_exceptions=False).
I suppose from my point of view, option 1 is the best we can do; default parameters just have to be done manually. I would be curious too if there were any better alternatives though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With