Tuple type options parses every character as an individual value #1314
-
First Check
Commit to Help
Example Codeimport typer
from typing import Tuple
from pathlib import Path
app = typer.Typer()
@app.command()
def useless(): # at least two commands are needed for typer to run properly
pass
@app.command()
def test(tupl: Tuple[Path] = typer.Option(None, '--tuple', '-t'), help='Tuple values'):
for x in tupl:
print(x)
app()
# RUN
# python3 app.py test -t AAA BBBBB
# PROBLEM
# should be interpreted as tuple("AAA", "BBBBB") but is interpreted as tuple("A", "A", "A")
# ERROR with : python3 app.py test -t AAA BBBBB
# Error: Invalid value for '--tuple' / '-t': 1 values are required, but 3 were given.
# ERROR with : python3 app.py test -t A B
# Error: Got unexpected extra argument (B)DescriptionI am trying to use a Tuple type option which is supposed to work as mentioned below : Operating SystemLinux Operating System DetailsUbuntu 20.04 LTS Typer Version0.4.0 Python Version3.8.10 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Your
https://typer.tiangolo.com/tutorial/multiple-values/options-with-multiple-values/ |
Beta Was this translation helpful? Give feedback.
Your
testshould be:def test(tupl: Tuple[Path, Path] = typer.Option(None, '--tuple', '-t'), help='Tuple values'):https://typer.tiangolo.com/tutorial/multiple-values/options-with-multiple-values/