def METHOD_NAME(typ, arg, name):
    if not isinstance(arg, typ):
        if isinstance(typ, tuple):
            assert len(typ) >= 2, "Use bare type instead of len-1 tuple"
            typ_string = "one of " + ", ".join(t.__name__ for t in typ)
        else:
            typ_string = typ.__name__
            if typ_string == "SearchStrategy":
                from hypothesis.strategies import SearchStrategy
                # Use hypothesis.strategies._internal.strategies.check_strategy
                # instead, as it has some helpful "did you mean..." logic.
                assert typ is not SearchStrategy, "use check_strategy instead"
        raise InvalidArgument(
            f"Expected {typ_string} but got {name}={arg!r} (type={type(arg).__name__})"
        )