diff --git a/doc/whatsnew/2/2.14/full.rst b/doc/whatsnew/2/2.14/full.rst index 71e692fb60..aa04fb76ec 100644 --- a/doc/whatsnew/2/2.14/full.rst +++ b/doc/whatsnew/2/2.14/full.rst @@ -5,6 +5,12 @@ What's New in Pylint 2.14.2? ---------------------------- Release date: TBA + +* Fixed a false positive for ``unused-variable`` when a function returns an + ``argparse.Namespace`` object. + + Closes #6895 + * Avoided raising an identical ``undefined-loop-variable`` message twice on the same line. * Don't crash if ``lint.run._query_cpu()`` is run within a Kubernetes Pod, that has only diff --git a/requirements_test_min.txt b/requirements_test_min.txt index 9b0d00ac8f..386f2605cb 100644 --- a/requirements_test_min.txt +++ b/requirements_test_min.txt @@ -1,6 +1,6 @@ -e .[testutils,spelling] # astroid dependency is also defined in setup.cfg -astroid==2.11.5 # Pinned to a specific version for tests +astroid==2.11.6 # Pinned to a specific version for tests typing-extensions~=4.2 pytest~=7.1 pytest-benchmark~=3.4 diff --git a/setup.cfg b/setup.cfg index 5cbc86df73..ebe3815fe9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,7 +47,7 @@ install_requires = # Also upgrade requirements_test_min.txt if you are bumping astroid. # Pinned to dev of next minor update to allow editable installs, # see https://github.com/PyCQA/astroid/issues/1341 - astroid>=2.11.5,<=2.12.0-dev0 + astroid>=2.11.6,<=2.12.0-dev0 isort>=4.2.5,<6 mccabe>=0.6,<0.8 tomli>=1.1.0;python_version<"3.11" diff --git a/tests/functional/u/unused/unused_variable_after_inference.py b/tests/functional/u/unused/unused_variable_after_inference.py new file mode 100644 index 0000000000..569564dc92 --- /dev/null +++ b/tests/functional/u/unused/unused_variable_after_inference.py @@ -0,0 +1,7 @@ +"""Regression test for https://github.com/PyCQA/pylint/issues/6895""" +# pylint: disable=missing-class-docstring,too-few-public-methods +import argparse +class Cls: + def meth(self): + """Enable non-iterator-returned to produce the failure condition""" + return argparse.Namespace(debug=True) diff --git a/tests/functional/u/unused/unused_variable_after_inference.rc b/tests/functional/u/unused/unused_variable_after_inference.rc new file mode 100644 index 0000000000..c3b20ca247 --- /dev/null +++ b/tests/functional/u/unused/unused_variable_after_inference.rc @@ -0,0 +1,2 @@ +[Messages Control] +enable=non-iterator-returned