Textualize / trogon

Easily turn your Click CLI into a powerful terminal application
MIT License
2.4k stars 54 forks source link

click tuple with diffrent data types #36

Open j-eser opened 1 year ago

j-eser commented 1 year ago

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.

darrenburns commented 1 year ago

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.

j-eser commented 1 year ago

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