I have a function as shown below:
from typing import List, Literal, Union
def foo(possible_values: List[Union[Literal['abcd', 'efgh', 'ijkl']]]):
return {}
Now this is how I want the code to behave:
whenever the possible_values parameter gets values other than ["abcd", "efgh","ijkl"]
Eg:
res = foo(possible_values=["abc", "efgh"])
It should throw an error as abc is not defined in the function signature.
However,
res = foo(possible_values=["abcd", "efgh"])
should work fine as they are subset of what is defined.
Currently, with the above code, it just accepts any arbitrary list of strings.