Pattern: Redefining argument with the local name
Issue: -
Used when a local name is redefining an argument, which might suggest a potential error.
This is taken in account only for a handful of name binding operations, such as for
iteration, with
statement assignment and exception handler assignment.
Example of incorrect code:
def test_redefined_in_with(name):
# The `with` is reusing `name`, which means that the following
# `name` is not what we wanted to check against.
with open('something') as name:
pass
Example of correct code:
def test_not_redefined_in_with(name):
other = None
with open('something') as other:
pass