Skip to content

Argument.make_metavar ignores ParamType.get_metavar ; is not configurable to fix #674

@sirosen

Description

@sirosen

If you do the following, you get bad behavior:

class MyType(click.ParamType):
    def get_metavar(self, param):
        return "MY_TYPE"

@click.command("foo")
@click.help_option()
@click.argument("param", type=MyType())
def foo_command(param):
    pass

foo --help produces a metavar of PARAM instead of the more logically correct MY_TYPE.

This is because Argument.make_metavar never looks at self.type.get_metavar(self).

Either this should be fixed so that Argument.make_metavar uses the type metavar by default, or Argument.make_metavar should take a parameter that lets you toggle between the default "name" metavar and the type's default metavar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions