Skip to content

How to migrate away from 'nameof'? #117

Closed
@zapta

Description

@zapta

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy