Closed
Description
We have a code similar to the one below where we use nameof
to convert arg names to strings. The advantage is that the ide tools are aware of the relation between the function args and nameof's args (e.g. when renaming or linting).
We tried to upgrade to the latest varname version and get a warning that we should use argname() instead but it seems to require the name of the arg a a string which defeats the reason we use varname.
Are we missing anything? What is the use case of argname() if the user requires to provide the arg name string?
def cli(
cmd_ctx: click.core.Context,
# Options:
ftdi_install: bool,
ftdi_uninstall: bool,
serial_install: bool,
serial_uninstall: bool,
):
"""Implements the drivers command."""
# User should select exactly on of these operations.
cmd_util.check_exactly_one_param(
cmd_ctx,
nameof(ftdi_install, ftdi_uninstall, serial_install, serial_uninstall),
)
Metadata
Metadata
Assignees
Labels
No labels