def _check_bad_default(name, trait, obj=None):
    if trait.vartypename not in ['Slot', 'VarTree'] and trait.required is True \
       and not trait.assumed_default and trait._illegal_default_ is True:

        msg = "variable '%s' is required and cannot have a default value" % name
        if obj is None:
            raise RuntimeError(msg)
        else:
            obj.raise_exception(msg, RuntimeError)
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/container.py/_check_bad_default/original