Skip to content

Tuples as Multi Value Options throw an TypeError #472

@xsteadfastx

Description

@xsteadfastx

Hi,

sorry if i do something wrong but i dont even get the example code working. i tried to put this into my code

@cli.command(help='Guess untranslated texts.')                                      
@click.argument('xml_file', type=click.File('r'))                                   
@click.option('--show', is_flag=True, help='Show untranslated texts.')              
@click.option('--html', type=click.File('w'), nargs=1,                              
              help='Write untranslated texts to html file.')                        
@click.option('--edit', type=click.File('w'), nargs=1,                              
              help='Edit untranslated texts.')                                      
@click.option('--csv-export', type=click.File('w'), nargs=1,                        
              help='Export untranslated texts to a csv file.')                      
@click.option('--csv-import', type=(click.File('r'), click.File('w')),              
              help='Imports csv changefile to another xml file.')                   
def untranslated(xml_file, show, html, edit, csv_export, csv_import):

And i will always get this

File "/home/xsteadfastx/Code/my-tools/env/lib/python3.4/site-packages/click/types.py", line 472, in convert
    raise TypeError('It would appear that nargs is set to conflict '
TypeError: It would appear that nargs is set to conflict with the composite type arity.

so i tried it with Python2.7... still the same error. Then i created a fresh Python2.7 virtualenv and used the example

import click


@click.command()
@click.option('--item', type=(unicode, int))
def putitem(item):
    click.echo('name=%s id=%d' % item)


putitem()

and running it with python foo.py still throws the error. I dont know if this is just a question, or if im doing something wrong and i know the "issues" section here is not for questions but maybe its some kind of a bug and i dont know what i else could do about this. so forgive me if its just my problem 😏

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions