from typing import Any
from typing import Callable


def with_attr(key: str, val: Any) -> Callable:
    """Adds a key-value pair as attribute to the decorated function."""

    def wrapper(func: Callable):
        setattr(func, key, val)
        return func

    return wrapper