Allows quick wrapping of any Python type cast function for use as a hug type annotation
(kind, doc=None, error_text=None, exception_handlers=empty.dict, accept_context=False)
| 209 | |
| 210 | |
| 211 | def accept(kind, doc=None, error_text=None, exception_handlers=empty.dict, accept_context=False): |
| 212 | """Allows quick wrapping of any Python type cast function for use as a hug type annotation""" |
| 213 | return create( |
| 214 | doc, |
| 215 | error_text, |
| 216 | exception_handlers=exception_handlers, |
| 217 | chain=False, |
| 218 | accept_context=accept_context, |
| 219 | )(kind) |
| 220 | |
| 221 | |
| 222 | number = accept(int, "A whole number", "Invalid whole number provided") |