# Path: src/errors.py
# class CallableError(Exception):
#     pass


import _weakref
import types
import logging
import atexit
from .errors import CallableError
            return init_args, init_kwargs
        else:
            # Fast paths.
            if not args and not kwargs:
                return init_args, init_kwargs
            elif not init_args and not init_kwargs:
                return args, kwargs

            # Slower paths, where we must copy kwargs in order to merge user
            # kwargs and invocation-time kwargs.
            if self._init_args_first:
                cb_args, cb_kwargs = init_args + args, kwargs.copy()
                cb_kwargs.update(init_kwargs)
            else:
                cb_args, cb_kwargs = args + init_args, init_kwargs.copy()
                cb_kwargs.update(kwargs)

        return cb_args, cb_kwargs


    def __call__(self, *args, **kwargs):
        """
        Invoke the callable.

        The arguments passed here take precedence over constructor arguments
        if the :attr:`~kaa.Callable.init_args_first` property is False (default).
        The wrapped callable's return value is returned.
        """
        cb = self._get_func()
        if cb is None:

# Path: src/errors.py
# class CallableError(Exception):
#     pass


# Path: src/callable.py
import _weakref
import types
import logging
import atexit
from .errors import CallableError

            return init_args, init_kwargs
        else:
            # Fast paths.
            if not args and not kwargs:
                return init_args, init_kwargs
            elif not init_args and not init_kwargs:
                return args, kwargs

            # Slower paths, where we must copy kwargs in order to merge user
            # kwargs and invocation-time kwargs.
            if self._init_args_first:
                cb_args, cb_kwargs = init_args + args, kwargs.copy()
                cb_kwargs.update(init_kwargs)
            else:
                cb_args, cb_kwargs = args + init_args, init_kwargs.copy()
                cb_kwargs.update(kwargs)

        return cb_args, cb_kwargs


    def __call__(self, *args, **kwargs):
        """
        Invoke the callable.

        The arguments passed here take precedence over constructor arguments
        if the :attr:`~kaa.Callable.init_args_first` property is False (default).
        The wrapped callable's return value is returned.
        """
        cb = self._get_func()
        if cb is None:

            raise CallableError('attempting to invoke an invalid callable')