4

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?

1 Answer 1

6

As far as I can surmise the only alternatives, from this issue, are to

  1. Call the underlying function like main.callback(*args). Then you're missing default arguments from the click interface.

  2. 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.