A small module assembles a batch of text templates for notifications. After a recent change, the behavior started to diverge from what was expected: independent calls begin to affect one another, and template labels sometimes do not match their own channel.
build_batch(channels) must return a list of dictionaries in the original channel order.channel: the channel name;template: a string of the form "Alert via <channel>";render: a zero-argument function returning a string of the form "[<channel>] Alert via <channel>".build_batch(...) call must not change the result of another independent call.channels is a regular iterable of strings; there should be no additional side effects.from templates import build_batch
first = build_batch(["email"])
second = build_batch(["sms"])
print([item["channel"] for item in first])
print([item["channel"] for item in second])
print(first[0]["render"]())
print(second[0]["render"]())
email channel, and the second only sms.render for each element must use exactly its own channel, not a value from another record or from the end of the loop.pythonbuild_batch(channels) functionUse line comments to explain the problem, its impact, the fix and how to test it.