def optional_args(decorator):
@wraps(decorator)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>def dec(f):<EOL><INDENT>return decorator(f, *args, **kwargs)<EOL><DEDENT>is_decorating = not kwargs and len(args) == <NUM_LIT:1> and callable(args[<NUM_LIT:0>])<EOL>if is_decorating:<EOL><INDENT>f = args[<NUM_LIT:0>]<EOL>args = []<EOL>return dec(f)<EOL><DEDENT>else:<EOL><INDENT>return dec<EOL><DEDENT><DEDENT>return wrapper<EOL>
allows a decorator to take optional positional and keyword arguments.
    Assumes that taking a single, callable, positional argument means that
    it is decorating a function, i.e. something like this::

        @my_decorator
        def function(): pass

    Calls decorator with decorator(f, *args, **kwargs)