# Buggy code
def _get_schedule(self, include_opts=True, include_pillar=True, remove_hidden=False):
    """
    Return the schedule data structure
    """
    schedule = {}
    if include_pillar:
        pillar_schedule = self.opts.get("pillar", {}).get("schedule", {})
        if not isinstance(pillar_schedule, dict):
            raise ValueError("Schedule must be of type dict.")
        schedule.update(pillar_schedule)
    if include_opts:
        opts_schedule = self.opts.get("schedule", {})
        if not isinstance(opts_schedule, dict):
            raise ValueError("Schedule must be of type dict.")
        schedule.update(opts_schedule)

    if remove_hidden:
        _schedule = copy.deepcopy(schedule)
        for job in _schedule:
            for item in _schedule[job]:
                if item.startswith("_"):
                    del schedule[job][item]
    return schedule


# Traceback (TypeError)
[ERROR   ] Exception in callback functools.partial(<function wrap.<locals>.null_wrapper at 0x7fee3181ebf8>, <tornado.concurrent.Future object at 0x7fee2972fc18>)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/tornado/stack_context.py", line 277, in null_wrapper
yielded = self.gen.throw(*exc_info)
File "/usr/lib/python3/dist-packages/tornado/concurrent.py", line 238, in result
raise_exc_info(self._exc_info)
File "/usr/lib/python3/dist-packages/salt/minion.py", line 946, in handle_event
yield [minion.handle_event(package) for minion in self.minions]
future.result()
ret = callback()
return fn(*args, **kwargs)
File "/usr/lib/python3/dist-packages/tornado/ioloop.py", line 626, in _discard_future_result
File "/usr/lib/python3/dist-packages/tornado/concurrent.py", line 238, in result
value = future.result()
File "<string>", line 4, in raise_exc_info
File "/usr/lib/python3/dist-packages/tornado/gen.py", line 1063, in run
File "/usr/lib/python3/dist-packages/tornado/gen.py", line 1055, in run
File "/usr/lib/python3/dist-packages/salt/utils/schedule.py", line 381, in modify_job
self.delete_job(name, persist)
raise_exc_info(self._exc_info)
result_list.append(f.result())
raise_exc_info(self._exc_info)
File "/usr/lib/python3/dist-packages/salt/minion.py", line 2135, in manage_schedule
self.schedule.modify_job(name, schedule, persist)
File "<string>", line 4, in raise_exc_info
File "/usr/lib/python3/dist-packages/tornado/concurrent.py", line 238, in result
File "<string>", line 4, in raise_exc_info
yielded = next(result)
File "/usr/lib/python3/dist-packages/salt/minion.py", line 2275, in handle_event
self.manage_schedule(tag, data)
File "/usr/lib/python3/dist-packages/tornado/gen.py", line 828, in callback
File "/usr/lib/python3/dist-packages/tornado/gen.py", line 307, in wrapper
File "/usr/lib/python3/dist-packages/salt/utils/schedule.py", line 257, in delete_job
remove_hidden=True)
for item in _schedule[job]:
self.persist()
TypeError: 'bool' object is not iterable
File "/usr/lib/python3/dist-packages/salt/utils/schedule.py", line 158, in _get_schedule
File "/usr/lib/python3/dist-packages/salt/utils/schedule.py", line 222, in persist

# Fixed code
def _get_schedule(self, include_opts=True, include_pillar=True, remove_hidden=False):
    """
    Return the schedule data structure
    """
    schedule = {}
    if include_pillar:
        pillar_schedule = self.opts.get("pillar", {}).get("schedule", {})
        if not isinstance(pillar_schedule, dict):
            raise ValueError("Schedule must be of type dict.")
        schedule.update(pillar_schedule)
    if include_opts:
        opts_schedule = self.opts.get("schedule", {})
        if not isinstance(opts_schedule, dict):
            raise ValueError("Schedule must be of type dict.")
        schedule.update(opts_schedule)

    if remove_hidden:
        _schedule = copy.deepcopy(schedule)
        for job in _schedule:
            if isinstance(_schedule[job], dict):
                for item in _schedule[job]:
                    if item.startswith("_"):
                        del schedule[job][item]
    return schedule