from typing import Tuple
import re


def parse_date(term: str) -> Tuple[str, str]:
    """
    Attempt to find date-related information in the query.

    Parameters
    ----------
    term : str
        Search term.

    Returns
    -------
    tuple
        First element is the responding date-related fragment, second element
        is the remainder of `term` (without the date).

    Raises
    ------
    ValueError
        Raised if no date-related information is found in `term`.

    """
    match = re.search(r"(?:^|[\s]+)([0-9]{4}-[0-9]{2})(?:$|[\s]+)", term)
    if match:
        remainder = term[: match.start()] + " " + term[match.end() :]
        return match.group(1), remainder.strip()

    match = re.search(r"(?:^|[\s]+)([0-9]{4})(?:$|[\s]+)", term)
    if match:  # Looks like a year:
        remainder = term[: match.start()] + " " + term[match.end() :]
        return match.group(1), remainder.strip()
    raise ValueError("No date info detected")