Skip to content

SCR104: redefined-unused

Function, class or import redefined before it is used

Code SCR104
Name redefined-unused
Category Scripts (SCR)
Default severity warning
Enabled by default yes
Fix available no
ign-lint equivalent none

Reports a def, class or import that rebinds a name whose previous def, class or import is still live there and is never read on any path. The analysis follows control flow: definitions in different branches of an if do not redefine each other, and a fallback import in an except ImportError: handler does not redefine the import it replaces. A read in the body of a class statement at the top level of the module that comes after both definitions (class A: f = f) reads only the second one, so it does not keep the first one used.

The first definition is dead code. Usually it is a copy-paste mistake: two functions with the same name in a library module, where callers only ever get the second one.

def formatValue(v):
return "%.2f" % v
def formatValue(v, unit):
return "%.2f %s" % (v, unit)

Use instead: give the functions different names, or delete the first one.

Corresponds to E0102 function-redefined, W0404 reimported and pyflakes' redefinition of unused name. pylint also reports redefinitions of names that were used in between; iglint only reports definitions that are never used.


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