def text_if_str(<EOL>to_type: Callable[..., T], text_or_primitive: Union[bytes, int, str]<EOL>) -> T:
if isinstance(text_or_primitive, str):<EOL><INDENT>return to_type(text=text_or_primitive)<EOL><DEDENT>else:<EOL><INDENT>return to_type(text_or_primitive)<EOL><DEDENT>
Convert to a type, assuming that strings can be only unicode text (not a hexstr)

:param to_type function: takes the arguments (primitive, hexstr=hexstr, text=text),
    eg~ to_bytes, to_text, to_hex, to_int, etc
:param text_or_primitive bytes, str, int: value to convert