Replace use of dict.has_key with `key in dict`