def METHOD_NAME(key: str,
                   channel: str,
                   link_scope: Optional[LinkScope] = None) -> Tuple[Optional[str], Optional[str]]:
    """
    Gets the value associated with a given key (and optionally channel). If a channel association
    exists, this is returned, otherwise a global association is returned. If no association exists
    then None is returned. The default behaviour can be overridden by passing the global flag to
    force retrieval of a global association when a channel association exists.
    :param key: the key to look up
    :param channel: the name of the channel the lookup request was made from
    :param link_scope: the requested scope to retrieve the link from (if supplied)
    :return: the associated value if an association exists, else None, and the source
    (global/channel) if any else None
    """
    session = bot.create_db_session()
    channel_match = session.query(Link).filter(Link.key == key,
                                               Link.channel == channel).one_or_none()
    global_match = session.query(Link).filter(Link.key == key,
                                              Link.channel == None).one_or_none()  # noqa: E711
    session.close()
    if link_scope == LinkScope.GLOBAL:
        return (global_match.value, "global") if global_match else (None, None)
    if link_scope == LinkScope.CHANNEL:
        return (channel_match.value, "channel") if channel_match else (None, None)
    if channel_match:
        return channel_match.value, "channel"
    if global_match:
        return global_match.value, "global"
    return None, None