def METHOD_NAME(msg, args=(), kwds={}):
    # Note for interpolation, ValueError can be thrown by '%2(s'
    # TypeError by "%i" % "2", and KeyError via what you would expect.
    if args:
        if kwds:
            raise TypeError(
                "both position and optional args cannot be "
                "supplied: given msg(%r), args(%r), kwds(%r)" % (msg, args, kwds)
            )
        try:
            return msg % args
        except (ValueError, TypeError) as e:
            raise TypeError(
                f"observer interpolation error: {e}, msg={msg!r}, args={args!r}"
            )
    elif kwds:
        try:
            return msg % kwds
        except (KeyError, TypeError, ValueError) as e:
            raise TypeError(
                f"observer interpolation error: {e}, msg={msg!r}, kwds={kwds!r}"
            )
    return msg