# -*- encoding: utf-8 -*-

from typing import Callable
from typing import Dict
from typing import Any


class KeywordArgumentsSetter(object):
    def __init__(self, **kwargs_changes: Dict[str, Any]):
        for oldkw in kwargs_changes.keys():
            assert isinstance(oldkw, str)
        self.kwargs_changes = kwargs_changes

    def __call__(self, c):
        return KeywordArgumentsRenamerConfigured(c, **self.kwargs_changes)


class KeywordArgumentsSetterConfigured(object):  # Don't instantiate this class manually
    def __init__(self, clb: Callable, **kwargs_changes: Dict[str, Any]):
        self.kwargs_changes = kwargs_changes
        self.callback = clb
    
    def __call__(self, *args, **kwargs):
        newkwargs = kwargs.copy()
        for k, v in self.kwargs_changes.items():
            newkwargs[k] = v
        return self.callback(*args, **newkwargs)