If a local variable is declared but not used, it is dead code and should be removed. Doing so will improve maintainability because developers will not wonder what the variable is used for.
def hello(name):
message = "Hello " + name # Noncompliant
print(name)
for i in range(10):
foo()
def hello(name):
message = "Hello " + name
print(message)
for _ in range(10):
foo()
_ as well as tuples will not raise an issue for this rule. The following examples are compliant:
for _ in range(10):
do_something()
username, login, password = auth
do_something_else(username, login)