Skip to content

SCR108: duplicate-dict-key

Dict literal has the same constant key twice

Code SCR108
Name duplicate-dict-key
Category Scripts (SCR)
Default severity warning
Enabled by default yes
Fix available no
ign-lint equivalent none

Reports keys of a dict literal that repeat an earlier constant key, with Python 2.7 equality:

  • numbers by value: 1, 1L, 1.0, True and 1+0j are the same key, as are 0, -0.0, 0j and False; 1e16 equals 10000000000000000 but not 10000000000000001;
  • strings: a str and a unicode with the same ASCII text are the same key; a str with non-ASCII bytes never equals a unicode ('\xe9' and u'\xe9' are two keys);
  • None, and tuples of such constants ((1, 2) and (1.0, 2L)).

True, False and None count only where they are Jython's builtins: in Python 2 True = 2 makes True an ordinary variable, and from x import *, exec or writes through globals() may rebind them.

Number literals with +, - or ~ in front count as constants; other expressions do not.

Only the last value is kept; the earlier entry is silently lost. In Ignition this often hides a mistake in a payload, a column mapping or a style dict.

payload = {
"line": line,
"machine": machine,
"line": station,
}

Use instead:

payload = {
"line": line,
"machine": machine,
"station": station,
}

Corresponds to W0109 duplicate-key.


Generated from the rule metadata by iglint generate-docs; iglint rule SCR108 prints the same page in the terminal. Source: docs/rules/SCR108.md.