Skip to content

Files

Latest commit

 

History

History
27 lines (20 loc) · 725 Bytes

redefined-argument-from-local.md

File metadata and controls

27 lines (20 loc) · 725 Bytes

Pattern: Redefining argument with the local name

Issue: -

Description

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