pylint
pylint copied to clipboard
Disabling stop-iteration-return in an if block affects elif and else blocks
Steps to reproduce
def func(value):
yield 1
generator = (x for x in range(10))
if value == 1:
# pylint: disable=unused-variable,stop-iteration-return
pass
elif value == 2:
abc = 1
next(generator)
else:
ghi = 1
next(generator)
Current behavior
For the elif and else blocks pylint only reports unused-variable. If the disable in the if block is removed it also reports stop-iteration-return for the elif and else blocks.
Expected behavior
Disable directives should only affect the block they are declared in. I did not test whether other tests than stop-iteration-return are affected as well. At least unused-variable does not show this bug.
pylint --version output
pylint 2.4.1
astroid 2.3.0
Python 3.7.3 (default, Apr 3 2019, 19:16:38)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
Yeah, this is definitely a bug, thanks for reporting it.