import click
from typing import Union
from typing import List


def check_table_params(ctx: click.Context, param: Union[click.Option, click.Parameter], value: List[str]) -> List[str]:
    """Check that 'tables' have been specified if 'include-dependent-tables' CLI is provided."""
    assert param.name == 'tables'
    other_flag = 'include_dependent_tables'
    if len(value) == 0 and other_flag in ctx.params and ctx.params[other_flag] is True:
        raise click.UsageError(
            "Illegal usage: '{}' option is only valid if '{}' arguments have been specified."
            .format(other_flag, param.name))
    return value