This rule raises an issue when the same key is used multiple times when instantiating a dictionary literal.
By definition, a dictionary cannot hold the same key multiple times. When instantiating a dictionary literal, if a key is repeated, only the last occurrence of the key will be retained.
This can lead to errors and confusion, as it is not clear which value belongs to which key. This can be remedied by either:
{"one": 1, "two": 2, "one": 3} # Noncompliant: the key "one" is duplicated.
def func(a1, a2):
{a1: 1, a2: 2, a1: 3} # Noncompliant: the key a1 is duplicated.
{"one": 1, "two": 2, "three": 3}
def func(a1, a2):
{a1: 1, a2: 2}