Closed thorwhalen closed 1 year ago
Wraps a function to add validation of the input arguments annotated with Literal against the values listed by the literal. If the input argument is not one of the literal values, a ValueError is raised.
>>> @validate_literal ... def f(x: Literal[1, 2, 3]): ... return x >>> f(1) 1 >>> f(4) # raises error
Closed with this commit
Wraps a function to add validation of the input arguments annotated with Literal against the values listed by the literal. If the input argument is not one of the literal values, a ValueError is raised.