def kwarg_decorator(func):
@wraps(func)<EOL>def decorator(arg=None, **kwargs):<EOL><INDENT>if arg is None:<EOL><INDENT>return lambda arg: decorator(arg, **kwargs)<EOL><DEDENT>return func(arg, **kwargs)<EOL><DEDENT>return decorator<EOL>
Turns a function that accepts a single arg and some kwargs in to a
decorator that can optionally be called with kwargs:

.. code-block:: python

    @kwarg_decorator
    def my_decorator(func, bar=True, baz=None):
        ...

    @my_decorator
    def my_func():
        pass

    @my_decorator(bar=False)
    def my_other_func():
        pass