def robust_isinstance(inst, typ) -> bool:
if typ is Any:<EOL><INDENT>return True<EOL><DEDENT>if is_typevar(typ):<EOL><INDENT>if hasattr(typ, '<STR_LIT>') and typ.__constraints__ is not None:<EOL><INDENT>typs = get_args(typ, evaluate=True)<EOL>return any(robust_isinstance(inst, t) for t in typs)<EOL><DEDENT>elif hasattr(typ, '<STR_LIT>') and typ.__bound__ is not None:<EOL><INDENT>return robust_isinstance(inst, typ.__bound__)<EOL><DEDENT>else:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if is_union_type(typ):<EOL><INDENT>typs = get_args(typ, evaluate=True)<EOL>return any(robust_isinstance(inst, t) for t in typs)<EOL><DEDENT>else:<EOL><INDENT>return isinstance(inst, get_base_generic_type(typ))<EOL><DEDENT><DEDENT>
Similar to isinstance, but if 'typ' is a parametrized generic Type, it is first transformed into its base generic
class so that the instance check works. It is also robust to Union and Any.

:param inst:
:param typ:
:return: