def csp_exempt()

in csp/decorators.py [0:0]


def csp_exempt(REPORT_ONLY: bool | None = None) -> _VIEW_DECORATOR_T:
    if callable(REPORT_ONLY):
        raise RuntimeError(
            "Incompatible `csp_exempt` decorator usage. This decorator now requires arguments, "
            "even if none are passed. Change bare decorator usage (@csp_exempt) to parameterized "
            "decorator usage (@csp_exempt()). See the django-csp 4.0 migration guide for more "
            "information."
        )

    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_exempt_ro", True)
            else:
                setattr(resp, "_csp_exempt", True)
            return resp

        return _wrapped

    return decorator