src/flask_allows/allows.py
def run(
        self,
        requirements,
        identity=None,
        throws=None,
        on_fail=None,
        f_args=(),
        f_kwargs=ImmutableDict(),  # noqa: B008
        use_on_fail_return=True,
    ):
        """
        Used to preform a full run of the requirements and the options given,
        this method will invoke on_fail and/or throw the appropriate exception
        type. Can be passed arguments to call on_fail with via f_args (which are
        passed positionally) and f_kwargs (which are passed as keyword).

        :param requirements: The requirements to check
        :param identity: Optional. A specific identity to use for the check
        :param throws: Optional. A specific exception to throw for this check
        :param on_fail: Optional. A callback to invoke after failure,
            alternatively a value to return when failure happens
        :param f_args: Positional arguments to pass to the on_fail callback
        :param f_kwargs: Keyword arguments to pass to the on_fail callback
        :param use_on_fail_return: Boolean (default True) flag to determine
            if the return value should be used. If true, the return value
            will be considered, else failure will always progress to
            exception raising.
        """

        throws = throws or self.throws
        on_fail = _make_callable(on_fail) if on_fail is not None else self.on_fail

        if not self.fulfill(requirements, identity):
            result = on_fail(*f_args, **f_kwargs)
            if use_on_fail_return and result is not None:
                return result
            raise throws
def run(
        self,
        requirements,
        identity=None,
        throws=None,
        on_fail=None,
        f_args=(),
        f_kwargs=ImmutableDict(),  # noqa: B008
        use_on_fail_return=True,
    ):
        """
        Used to preform a full run of the requirements and the options given,
        this method will invoke on_fail and/or throw the appropriate exception
        type. Can be passed arguments to call on_fail with via f_args (which are
        passed positionally) and f_kwargs (which are passed as keyword).

        :param requirements: The requirements to check
        :param identity: Optional. A specific identity to use for the check
        :param throws: Optional. A specific exception to throw for this check
        :param on_fail: Optional. A callback to invoke after failure,
            alternatively a value to return when failure happens
        :param f_args: Positional arguments to pass to the on_fail callback
        :param f_kwargs: Keyword arguments to pass to the on_fail callback
        :param use_on_fail_return: Boolean (default True) flag to determine
            if the return value should be used. If true, the return value
            will be considered, else failure will always progress to
            exception raising.
        """

        throws = throws or self.throws
        on_fail = _make_callable(on_fail) if on_fail is not None else self.on_fail

        if not self.fulfill(requirements, identity):
            result = on_fail(*f_args, **f_kwargs)
            if use_on_fail_return and result is not None:
                return result
            raise throws
Used to preform a full run of the requirements and the options given,
        this method will invoke on_fail and/or throw the appropriate exception
        type. Can be passed arguments to call on_fail with via f_args (which are
        passed positionally) and f_kwargs (which are passed as keyword).

        :param requirements: The requirements to check
        :param identity: Optional. A specific identity to use for the check
        :param throws: Optional. A specific exception to throw for this check
        :param on_fail: Optional. A callback to invoke after failure,
            alternatively a value to return when failure happens
        :param f_args: Positional arguments to pass to the on_fail callback
        :param f_kwargs: Keyword arguments to pass to the on_fail callback
        :param use_on_fail_return: Boolean (default True) flag to determine
            if the return value should be used. If true, the return value
            will be considered, else failure will always progress to
            exception raising.