trogon icon indicating copy to clipboard operation
trogon copied to clipboard

click tuple with diffrent data types

Open j-eser opened this issue 2 years ago • 2 comments

If I try to use click.Tuple with 2 different data types i.e. type=click.Tuple([float, str]), default=(0.0, 'test') The TUI breaks with this error: TypeError: '<' not supported between instances of 'float' and 'str'

It works fine if no default is provided or the default is set to None. It also works if both tuple values are str. Not sure if that is a known issue or if it is on my side.

j-eser avatar May 31 '23 21:05 j-eser

I've tried to reproduce this but can't.

If you can write a really small Click app, just a few lines, that shows this error happening I can look to debug it.

darrenburns avatar Jun 06 '23 10:06 darrenburns

Oh sorry, I should hve added it before

import click
from trogon import tui

@tui()
@click.command()
@click.option('--tuple', 'test_tuple', type=click.Tuple([float, str]), default=(0.0, 'test'), help="Just a test for failure")
def test(test_tuple):
    click.echo(f"Hello tuple: {test_tuple}!")

if __name__ == "__main__":
    test()

If I run it not with tui it works but the tui command end in TypeError: '<' not supported between instances of 'str' and 'float' I also should note that chnages the tuple to hold the same data type it is working as well. Even though only the first default value is shown in the TUI. Setting no default value works. Also I am using python=3.11.3 click=8.1.3 trogon=0.4.0

j-eser avatar Jun 06 '23 20:06 j-eser