pylint icon indicating copy to clipboard operation
pylint copied to clipboard

cell-var-from-loop (W0640): why

Open bersbersbers opened this issue 2 years ago • 4 comments

Bug description

I don't see why the code in this example file

https://github.com/PyCQA/pylint/blob/96e84595194073ea54a8c7730b86125049c0f4f9/tests/functional/n/nested_func_defined_in_loop.py#L1-L10

is problematic. When called using example(range(4)), it outputs

0
1
2
3
0
1
2
3

which looks correct to me. See also https://github.com/vald-phoenix/pylint-errors/issues/7

Configuration

No response

Command used

wget https://raw.githubusercontent.com/PyCQA/pylint/main/tests/functional/n/nested_func_defined_in_loop.py
pylint nested_func_defined_in_loop.py

Pylint output

************* Module nested_func_defined_in_loop
nested_func_defined_in_loop.py:7:18: W0640: Cell variable i defined in loop (cell-var-from-loop)

-----------------------------------
Your code has been rated at 8.57/10

Expected behavior

No error

Pylint version

pylint 2.11.1
astroid 2.8.4
Python 3.9.6 (default, Jan  1 1970, 00:00:00) 
[GCC 7.5.0]

OS / Environment

OpenSUSE Leap 15.2

Additional dependencies

No response

bersbersbers avatar Nov 05 '21 18:11 bersbersbers