diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-06-14 15:18:46 +0200 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-06-17 13:45:42 +0200 |
commit | cbd3cc07515e21ed08000941dc4883c86e84e208 (patch) | |
tree | 8d5a777fbe7898ee2423a9b24c42bfa5c5706872 /pylint/lint/pylinter.py | |
parent | 4dfaddf58129f1718340bf3b513a0270fe749354 (diff) | |
download | pylint-git-cbd3cc07515e21ed08000941dc4883c86e84e208.tar.gz |
No crash on bad plugin provided in configuration file
Raise an error 'bad-plugin-value' instead.
See #4555
Diffstat (limited to 'pylint/lint/pylinter.py')
-rw-r--r-- | pylint/lint/pylinter.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py index 46818fb83..67cd9bfd3 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -128,6 +128,11 @@ MSGS = { "bad-option-value", "Used when a bad value for an inline option is encountered.", ), + "E0013": ( + "Plugin '%s' is impossible to load, is it installed ? ('%s')", + "bad-plugin-value", + "Used when a bad value is used in 'load-plugins'.", + ), } @@ -531,8 +536,11 @@ class PyLinter( if modname in self._dynamic_plugins: continue self._dynamic_plugins.add(modname) - module = astroid.modutils.load_module_from_name(modname) - module.register(self) + try: + module = astroid.modutils.load_module_from_name(modname) + module.register(self) + except ModuleNotFoundError: + pass def load_plugin_configuration(self): """Call the configuration hook for plugins @@ -542,9 +550,12 @@ class PyLinter( settings. """ for modname in self._dynamic_plugins: - module = astroid.modutils.load_module_from_name(modname) - if hasattr(module, "load_configuration"): - module.load_configuration(self) + try: + module = astroid.modutils.load_module_from_name(modname) + if hasattr(module, "load_configuration"): + module.load_configuration(self) + except ModuleNotFoundError as e: + self.add_message("bad-plugin-value", args=(modname, e), line=0) def _load_reporters(self) -> None: sub_reporters = [] |