You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
holmanb opened this issue
Apr 18, 2024
· 0 comments
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation
The cell-var-from-loop warning shows up on conditional use of SystemExit's code property. This appears similar to, but not the same as #5508, which appears specific to keyword arguments.
Given the following code, run pylint on it. Note the comment.
importsysimportpytestdeftest_invalid_W0640():
""" This test demonstrates a false positive for W0640. Message emitted: Cell variable %s defined in loop Description: A variable used in a closure is defined in a loop. This will result in all closures using the same value for the closed-over variable. """defrun_closure(closure):
closure()
foriinrange(5):
withpytest.raises(SystemExit) ase:
# pylint incorrectly thinks that the following closure will cause# all runs to have to same valuerun_closure(lambda*_: sys.exit(i))
asserte.value.code==i
DanielNoord
added
False Positive 🦟
A message is emitted but nothing is wrong with the code
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
and removed
Needs triage 📥
Just created, needs acknowledgment, triage, and proper labelling
labels
Apr 19, 2024
False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation
Bug description
The cell-var-from-loop warning shows up on conditional use of SystemExit's code property. This appears similar to, but not the same as #5508, which appears specific to keyword arguments.
Given the following code, run pylint on it. Note the comment.
Configuration
No response
Command used
Pylint output
Expected behavior
No error
Pylint version
OS / Environment
Ubuntu 24.04, pylint installed via pip
Additional dependencies
pytest if you want to demonstrate that the code works as intended
The text was updated successfully, but these errors were encountered: