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

cell-var-from-loop false positive for keyword-only arguments #5012

Closed
olmokramer opened this issue Sep 15, 2021 · 0 comments · Fixed by #5045
Closed

cell-var-from-loop false positive for keyword-only arguments #5012

olmokramer opened this issue Sep 15, 2021 · 0 comments · Fixed by #5045
Labels
Milestone

Comments

@olmokramer
Copy link

Bug description

# pylint: disable=missing-docstring,invalid-name
for i in range(5):
    def f(*, _i=i):
        print(_i)
    f()
    def g(_i=i):
        print(_i)
    g()

Configuration

No response

Command used

pylint pylint_repro.py

Pylint output

************* Module pylint_repro
pylint_repro.py:3:16: W0640: Cell variable i defined in loop (cell-var-from-loop)

Expected behavior

I would expect the cell-var-from-loop not to be triggered because the value is bound to a keyword argument. The message is only triggered in the presence of the * that forces all following arguments to be keyword-only, i.e. it is triggered for f but not for g.

Pylint version

pylint 2.10.2
astroid 2.7.3
Python 3.9.2 (default, Mar 15 2021, 17:11:34)

OS / Environment

Ubuntu 20.04.3 LTS, Python installed with pyenv.

Additional dependencies

No response

@olmokramer olmokramer added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 15, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.11.2 milestone Sep 20, 2021
@Pierre-Sassoulas Pierre-Sassoulas removed the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants