# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in project root for information.
from functools import wraps
[docs]def keywords_catch(func):
"""
A decorator that forces keyword arguments in the wrapped method
and saves actual input keyword arguments in `_kwargs`.
Notes
-----
Should only be used to wrap a method where first arg is `self`
"""
@wraps(func)
def wrapper(self, *args, **kwargs):
if len(args) > 0:
raise TypeError("Method %s forces keyword arguments." % func.__name__)
self._kwargs = kwargs
return func(self, **kwargs)
return wrapper