Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined-loop-variable in presence of cell-var-from-loop #2121

Closed
sk- opened this issue May 19, 2018 · 3 comments
Closed

undefined-loop-variable in presence of cell-var-from-loop #2121

sk- opened this issue May 19, 2018 · 3 comments
Labels

Comments

@sk-
Copy link

sk- commented May 19, 2018

Similar to bug #1921 and related, I found that an extra undefined-loop-variable error is shown in presence of cell-var-from-loop when the same variable is used later in another loop.

Steps to reproduce

The following code:

def call(f, a):
    return f(a)
for x in [1]:
    call(lambda a: a+x, 3)
for x in [2]:
    pass

outputs

W:  4,21: Cell variable x defined in loop (cell-var-from-loop)
W:  4,21: Using possibly undefined loop variable 'x' (undefined-loop-variable)

However, when changing the name of the second x or commenting out those two lines, then the output is just

W:  4,21: Cell variable x defined in loop (cell-var-from-loop)

pylint --version output

No config file found, using default configuration
pylint 1.8.4,
astroid 1.6.3
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
@PCManticore
Copy link
Contributor

Thanks for the bug report!

@SamyCookie
Copy link

Does #2276 fixed this issue ?

@Pierre-Sassoulas
Copy link
Member

Closing as it's fixed on main, thank you for the help @SamyCookie and @david-yz-liu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants