def _parse_multiformat(self, string: str, formats: Iterable[str]) -> datetime:
        """
        Parse a date and time string using multiple formats.

        Tries to parse the provided string with each format in the given `formats`
        iterable, returning the resulting `datetime` object if a match is found. If no
        format matches the string, a `ParserError` is raised.

        :param string: The date and time string to parse.
        :type string: str
        :param formats: An iterable of date and time format strings to try, in order.
        :type formats: Iterable[str]
        :returns: The parsed date and time.
        :rtype: datetime.datetime
        :raises ParserError: If no format matches the input string.
        """
        _datetime: Optional[datetime] = None

        for fmt in formats:
            try:
                _datetime = self.parse(string, fmt)
                break
            except ParserMatchError:
                pass

        if _datetime is None:
            supported_formats = ", ".join(formats)
            raise ParserError(
                f"Could not match input {string!r} to any of the following formats: {supported_formats}."
            )

        return _datetime

        Parse a date and time string using multiple formats.

        Tries to parse the provided string with each format in the given `formats`
        iterable, returning the resulting `datetime` object if a match is found. If no
        format matches the string, a `ParserError` is raised.

        :param string: The date and time string to parse.
        :type string: str
        :param formats: An iterable of date and time format strings to try, in order.
        :type formats: Iterable[str]
        :returns: The parsed date and time.
        :rtype: datetime.datetime
        :raises ParserError: If no format matches the input string.
        
arrow/parser.py