def __setitem__(self, key, value):
if key in self.valid_keys:<EOL><INDENT>self.seen_keys.add(key)<EOL>self.data[key] = value<EOL><DEDENT>else:<EOL><INDENT>raise KeyError(key)<EOL><DEDENT>
Trying to add an invalid key will raise KeyError