def f():
x: int = 0
y = 0
def inner():
nonlocal x, y
x += 1
y += 1
return x + y
print(inner(), inner())
pylint a.pyThere is a lint failure: a.py:2:4: W0612: Unused variable 'x' (unused-variable)
There is no such lint failure for y.
No unused-variable lint failures, since both variables are used as nonlocal inside inner.
pylint 2.2.2
astroid 2.1.0
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)]
Thanks for reporting a bug!
I'm still seeing this also on outer function arguments with latest version (2.3.1) and also without type annotations. Am I missing something??
a.py:
# pylint: disable=invalid-name, missing-docstring
def f(x, y):
def inner():
nonlocal x, y
x += 1
y += 1
return x + y
print(inner(), inner())
pylint a.py:
************* Module a
D:\Temp\a.py:3:6: W0613: Unused argument 'x' (unused-argument)
D:\Temp\a.py:3:9: W0613: Unused argument 'y' (unused-argument)
--------------------------------------------------------------------
Your code has been rated at 7.14/10 (previous run: -2.86/10, +10.00)
pylint --version:
pylint 2.3.1
astroid 2.2.5
Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)]