def csp()

in csp/decorators.py [0:0]


def csp(config: dict[str, Any] | None = None, REPORT_ONLY: bool = False, **kwargs: Any) -> _VIEW_DECORATOR_T:
    if config is None and kwargs:
        raise RuntimeError(DECORATOR_DEPRECATION_ERROR.format(fname="csp"))

    if config is None:
        processed_config: dict[str, list[Any]] = {}
    else:
        processed_config = {k: [v] if isinstance(v, str) else v for k, v in config.items()}

    def decorator(f: _VIEW_T) -> _VIEW_T:
        @wraps(f)
        def _wrapped(*a: Any, **kw: Any) -> HttpResponseBase:
            resp = f(*a, **kw)
            if REPORT_ONLY:
                setattr(resp, "_csp_config_ro", processed_config)
            else:
                setattr(resp, "_csp_config", processed_config)
            return resp

        return _wrapped

    return decorator