Tuple parsing is failing with Literals. See the example below.
from tap import Tap
from typing import Literal
class Args(Tap):
arg: tuple[Literal['a', 'b'], ...]
args = Args().parse_args(['--arg', 'a', 'b'])
Running the above code produces the error argument --arg: invalid <tap.utils.TupleTypeEnforcer object at 0x7fe3937cb2e0> value: 'a'
In contrast, the following code works correctly, indicating that it is specifically a problem with the Literal type.
from tap import Tap
from typing import Literal
class Args(Tap):
arg: tuple[str, ...]
args = Args().parse_args(['--arg', 'a', 'b'])
Additionally, the following code, which uses list in place of tuple, also works, so it is specifically the combination of tuples and Literals that has an issue.
from tap import Tap
from typing import Literal
class Args(Tap):
arg: list[Literal['a', 'b']]
args = Args().parse_args(['--arg', 'a', 'b'])
Tuple parsing is failing with Literals. See the example below.
Running the above code produces the error
argument --arg: invalid <tap.utils.TupleTypeEnforcer object at 0x7fe3937cb2e0> value: 'a'
In contrast, the following code works correctly, indicating that it is specifically a problem with the Literal type.
Additionally, the following code, which uses
list
in place oftuple
, also works, so it is specifically the combination of tuples and Literals that has an issue.