All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.py.rules.python.S5780.html Maven / Gradle / Ivy

A dictionary cannot have two values with the same key. When a key is repeated in a dictionary literal, only the last occurence will remain. Thus duplicate keys should be either modified or removed.

This rule raises an issue when the same value is used multiple times as a key in a dictionary literal.

Noncompliant Code Example

{"one": 1, "two": 2, "one": 3}  # Noncompliant

def func(a1, a2, a3):
    {a1: 1, a2: 2, a1: 3}  # Noncompliant.

Compliant Solution

{"one": 1, "two": 2, "three": 3}

def func(a1, a2, a3):
    {a1: 1, a2: 2, a3: 3}

See





© 2015 - 2025 Weber Informatics LLC | Privacy Policy