redefined-outer-name / W0621#
Redefining name %r from outer scope (line %s)
Used when a variable's name hides a name defined in an outer scope or except handler.
count = 10 def count_it(count): # [redefined-outer-name] for i in range(count): print(i)
count = 10 def count_it(limit): for i in range(limit): print(i)
A common issue is that this message is triggered when using pytest fixtures:
import pytest @pytest.fixture def setup(): ... def test_something(setup): # [redefined-outer-name] ...
One solution to this problem is to explicitly name the fixture:
@pytest.fixture(name="setup") def setup_fixture(): ...
Alternatively pylint plugins like pylint-pytest can be used.
Created by the variables checker.