Skip to content

Collide variable name between argument and option #2321

@nappex

Description

@nappex

I am not sure if it is a bug or advanced feature or intended behavior, but when I define argument and option with same variable name I have not received any error. It seems that click absolutely ignore defined option when its name collides with any argument var name. I missing some info about this case in documentation at least.

I've tried to google something as python click argument and option variable name conflict or python click argument and option variable name collision, but without success. So if the issue is not relevant I am apologize for disturbing.

If it is intended behavior, I can make PR to update documentation if you want.

Code example:

@click.argument('dest_path', required=False, type=click.Path(file_okay=False))
@click.option('-o', '--output', 'dest_path', type=click.Path(file_okay=False),
              help='Absolute or relative path to the output directory')
def main(dest_path):
    print(dest_name)
$ python -m library_module_name -o ~/build
None

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