diff --git a/ChangeLog b/ChangeLog index 76c92a0b78..e1214c40fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -399,6 +399,8 @@ Release date: TBA Closes #5862 +* Importing the deprecated stdlib module ``distutils`` now emits ``deprecated_module`` on Python 3.10+. + * ``missing-raises-doc`` will now check the class hierarchy of the raised exceptions .. code-block:: python diff --git a/doc/whatsnew/2.13.rst b/doc/whatsnew/2.13.rst index e7fc63b888..ff38993823 100644 --- a/doc/whatsnew/2.13.rst +++ b/doc/whatsnew/2.13.rst @@ -386,6 +386,8 @@ Other Changes Closes #5862 +* Importing the deprecated stdlib module ``distutils`` now emits ``deprecated_module`` on Python 3.10+. + * Fixed false positive ``unexpected-keyword-arg`` for decorators. Closes #258 diff --git a/pylint/checkers/stdlib.py b/pylint/checkers/stdlib.py index 864abf7349..8270eb88cc 100644 --- a/pylint/checkers/stdlib.py +++ b/pylint/checkers/stdlib.py @@ -79,6 +79,7 @@ (3, 6, 0): {"asynchat", "asyncore"}, (3, 7, 0): {"macpath"}, (3, 9, 0): {"lib2to3", "parser", "symbol", "binhex"}, + (3, 10, 0): {"distutils"}, } DEPRECATED_ARGUMENTS = { @@ -126,6 +127,7 @@ "abc.abstractstaticmethod", "abc.abstractproperty", }, + (3, 4, 0): {"importlib.util.module_for_loader"}, } @@ -205,6 +207,10 @@ }, (3, 4, 0): { "importlib.find_loader", + "importlib.abc.Loader.load_module", + "importlib.abc.Loader.module_repr", + "importlib.abc.PathEntryFinder.find_loader", + "importlib.abc.PathEntryFinder.find_module", "plistlib.readPlist", "plistlib.writePlist", "plistlib.readPlistFromBytes", @@ -253,6 +259,7 @@ }, (3, 10, 0): { "_sqlite3.enable_shared_cache", + "importlib.abc.Finder.find_module", "pathlib.Path.link_to", "zipimport.zipimporter.load_module", "zipimport.zipimporter.find_module", diff --git a/tests/functional/d/deprecated/deprecated_module_py310.py b/tests/functional/d/deprecated/deprecated_module_py310.py new file mode 100644 index 0000000000..8321474762 --- /dev/null +++ b/tests/functional/d/deprecated/deprecated_module_py310.py @@ -0,0 +1,4 @@ +"""Test deprecated modules from Python 3.10.""" +# pylint: disable=unused-import + +import distutils # [deprecated-module] diff --git a/tests/functional/d/deprecated/deprecated_module_py310.rc b/tests/functional/d/deprecated/deprecated_module_py310.rc new file mode 100644 index 0000000000..b29fd450ac --- /dev/null +++ b/tests/functional/d/deprecated/deprecated_module_py310.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver = 3.10 diff --git a/tests/functional/d/deprecated/deprecated_module_py310.txt b/tests/functional/d/deprecated/deprecated_module_py310.txt new file mode 100644 index 0000000000..a46667aa52 --- /dev/null +++ b/tests/functional/d/deprecated/deprecated_module_py310.txt @@ -0,0 +1 @@ +deprecated-module:4:0:4:16::Uses of a deprecated module 'distutils':UNDEFINED diff --git a/tests/functional/r/regression_02/regression_distutil_import_error_73.py b/tests/functional/r/regression_02/regression_distutil_import_error_73.py index 751a4980f7..d40c0973fe 100644 --- a/tests/functional/r/regression_02/regression_distutil_import_error_73.py +++ b/tests/functional/r/regression_02/regression_distutil_import_error_73.py @@ -7,7 +7,7 @@ https://github.com/PyCQA/astroid/pull/1321 """ -# pylint: disable=unused-import +# pylint: disable=unused-import, deprecated-module import distutils.version from distutils.util import strtobool