def typecasted(func):
signature = inspect.signature(func).parameters.items()<EOL>@wraps(func)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>args = list(args)<EOL>new_args = []<EOL>new_kwargs = {}<EOL>for _, param in signature:<EOL><INDENT>converter = param.annotation<EOL>if converter is inspect._empty:<EOL><INDENT>converter = lambda a: a  <EOL><DEDENT>if param.kind is param.POSITIONAL_OR_KEYWORD:<EOL><INDENT>if args:<EOL><INDENT>to_conv = args.pop(<NUM_LIT:0>)<EOL>new_args.append(converter(to_conv))<EOL><DEDENT><DEDENT>elif param.kind is param.VAR_POSITIONAL:<EOL><INDENT>for a in args:<EOL><INDENT>new_args.append(converter(a))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for k, v in kwargs.items():<EOL><INDENT>nk, nv = converter(k, v)<EOL>new_kwargs[nk] = nv<EOL><DEDENT><DEDENT><DEDENT>return func(*new_args, **new_kwargs)<EOL><DEDENT>return wrapper<EOL>
Decorator that converts arguments via annotations.