:deprecated: 1.0.0
    Use :class:`giveme.injector.Injector` instead.

    Inject dependencies into given function's arguments.
    By default the injector looks for keyword arguments
    matching registered dependency names.

    Example:

        @register
        def db_connection():
            return create_db_connection()

        @inject
        def save_thing(thing, db_connection=None):
            db_connection.store(thing)

    Arbitrary arguments may also be mapped to
    specific dependency names by passing them to the
    decorator as ``arg='dependency_name'``

    Example:
        @inject(db='db_connection')
        def save_thing(thing, db=None):  # `db_connection` injected as `db`

    Args:
        function (callable): The function that accepts a dependency.
            Implicitly passed when used as a decorator.
        **overridden_names: Mappings of `function` arguments to
            dependency names in the form of ``function_argument='dependency name'``

def inject(function=None, **overridden_names):
    """
    :deprecated: 1.0.0
    Use :class:`giveme.injector.Injector` instead.

    Inject dependencies into given function's arguments.
    By default the injector looks for keyword arguments
    matching registered dependency names.

    Example:

        @register
        def db_connection():
            return create_db_connection()

        @inject
        def save_thing(thing, db_connection=None):
            db_connection.store(thing)

    Arbitrary arguments may also be mapped to
    specific dependency names by passing them to the
    decorator as ``arg='dependency_name'``

    Example:
        @inject(db='db_connection')
        def save_thing(thing, db=None):  # `db_connection` injected as `db`

    Args:
        function (callable): The function that accepts a dependency.
            Implicitly passed when used as a decorator.
        **overridden_names: Mappings of `function` arguments to
            dependency names in the form of ``function_argument='dependency name'``
    """
    warnings.warn(
        (
            'Module level `inject` decorator has been deprecated and will '
            'be removed in a future release. '
            'Use the Injector class instead'
        ),
        DeprecationWarning
    )
    
    def decorator(function):        
        @wraps(function)
        def wrapper(*args, **kwargs):
            signature = inspect.signature(function)
            params = signature.parameters
            if not params:
                return function(*args, **kwargs)
            for name, param in params.items():
                if param.kind not in (param.KEYWORD_ONLY, param.POSITIONAL_OR_KEYWORD):
                    continue
                if name in kwargs:
                    # Manual override, ignore it
                    continue
                try:
                    resolved_name = overridden_names.get(name, name)
                    kwargs[name] = manager.get_value(resolved_name)
                except KeyError:
                    pass
            return function(*args, **kwargs)
        return wrapper
    if function:
        return decorator(function)
    else:
        return decorator