import typing


def get_param_query(sql: str, params: dict) -> typing.Tuple[str, tuple]:
    """
    Re-does a SQL query so that it uses asyncpg's special query format.

    :param sql: The SQL statement to use.
    :param params: The dict of parameters to use.
    :return: A two-item tuple of (new_query, arguments)
    """
    if not params or len(params) < 1:
        return sql, ()
    # Dump the params into key -> value pairs.
    kv = [(k, v) for (k, v) in params.items()]

    # Define the list of items that are used to return.
    items = []
    fmt_dict = {}

    # Iterate over the key-values, adding each key to the fmt_dict with the number index.
    for n, (k, v) in enumerate(kv):
        n += 1
        # Add to the format dict.
        fmt_dict[k] = "${}".format(n)
        items.append(v)

    # Finally, format the SQL with the required params.
    sql_statement = sql.format(**fmt_dict)

    return sql_statement, tuple(items)