diff options
author | Ian Stapleton Cordasco <graffatcolmingov@gmail.com> | 2021-11-05 10:10:52 -0500 |
---|---|---|
committer | Ian Stapleton Cordasco <graffatcolmingov@gmail.com> | 2021-11-05 10:10:52 -0500 |
commit | 5694f6f3af357d3461db62912e08a4f4326f2859 (patch) | |
tree | 97a7c06f1ae0c12df5b10493566a8d0e0ed26960 /src/flake8/exceptions.py | |
parent | 05cae7e046d515b8c2dceaa9c897f4c84c7ffb5f (diff) | |
download | flake8-plugin-loading.tar.gz |
Add --required-plugins and --allowed-pluginsplugin-loading
Closes #283
Closes #488
Diffstat (limited to 'src/flake8/exceptions.py')
-rw-r--r-- | src/flake8/exceptions.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/flake8/exceptions.py b/src/flake8/exceptions.py index 45db94d..14b50c9 100644 --- a/src/flake8/exceptions.py +++ b/src/flake8/exceptions.py @@ -1,5 +1,6 @@ """Exception classes for all of Flake8.""" from typing import Dict +from typing import List class Flake8Exception(Exception): @@ -69,3 +70,24 @@ class PluginExecutionFailed(Flake8Exception): "name": self.plugin["plugin_name"], "exc": self.original_exception, } + + +class PluginMissingError(Flake8Exception): + """A plugin that was required was not found.""" + + FORMAT = "User required %(plugins)s but %(missing)s was not found." + + def __init__( + self, required_plugins: List[str], missing_plugins: List[str] + ) -> None: + """Store the information passed in to format the exception message.""" + self.required_plugins = required_plugins + self.missing_plugins = missing_plugins + super().__init__(required_plugins, missing_plugins) + + def __str__(self) -> str: + """Format our exception message.""" + return self.FORMAT % { + "plugins": ", ".join(self.required_plugins), + "missing": ", ".join(self.missing_plugins), + } |