I recently ran into some code where the developer was expecting a create a dict with a single key and a value created by a generator comprehension. Instead they ended up with a dict comprehension with a single entry for the value:
data = ["some", "Data"]
out = {"key": value.upper() for value in data}
print(out)
Could a new inspection be added that detects the presence of a static key within a dict comprehension?
Expected:
data = ["some", "Data"]
out = {"key": value.upper() for value in data} # error: Static value for key in dict comprehension.
print(out)