Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

click tuple with diffrent data types #36

Open
j-eser opened this issue May 31, 2023 · 2 comments
Open

click tuple with diffrent data types #36

j-eser opened this issue May 31, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@j-eser
Copy link

j-eser commented May 31, 2023

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
Copy link
Member

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
Copy link
Author

j-eser commented Jun 6, 2023

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

@darrenburns darrenburns added the bug Something isn't working label Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants