rspec/rules/S2834/python/rule.adoc
2021-04-28 16:49:39 +02:00

17 lines
567 B
Plaintext

During dictionary use, it is normal that you might want to replace the value associated with one of the dictionary's keys. But do so during the initial definition of a dictionary, and you've probably made an error.
This rule raises an issue when the same key is used multiple times in the initial definition of a dictionary.
== Noncompliant Code Example
----
fruit = {"apple":4, "pear":6, "quince":29, "apple": 8} # Noncompliant; "apple" is used in positions 0 and 3
----
== Compliant Solution
----
fruit = {"apple":4, "pear":6, "quince":29, "potato": 8}
----