from typing import Any


def copy_with_str_subst(x: Any, substitutions: Any) -> Any:
    """Deep-copy a structure, carrying out string substitutions on any strings

    Args:
        x (object): structure to be copied
        substitutions (object): substitutions to be made - passed into the
            string '%' operator

    Returns:
        copy of x
    """
    if isinstance(x, str):
        return x % substitutions
    if isinstance(x, dict):
        return {k: copy_with_str_subst(v, substitutions) for (k, v) in x.items()}
    if isinstance(x, (list, tuple)):
        return [copy_with_str_subst(y, substitutions) for y in x]

    # assume it's uninterested and can be shallow-copied.
    return x