redefined-loop-name / W2901ΒΆ
Message emitted:
Redefining %r from loop (line %s)
Description:
Used when a loop variable is overwritten in the loop body.
Problematic code:
def normalize_names(names):
for name in names:
name = name.lower() # [redefined-loop-name]
Correct code:
def normalize_names(names):
for name in names:
lowercased_name = name.lower()
Configuration file:
[MAIN]
load-plugins=pylint.extensions.redefined_loop_name,
Note
This message is emitted by the optional 'redefined-loop-name'
checker, which requires the pylint.extensions.redefined_loop_name
plugin to be loaded.
Created by the redefined-loop-name checker.