mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 10:46:54 +00:00
Merge pull request #1489 from asottile/exceptions-plugin-name
use plugin_name= instead of dicts in exceptions
This commit is contained in:
commit
fed77cd60a
3 changed files with 12 additions and 13 deletions
|
|
@ -353,7 +353,7 @@ class FileChecker:
|
|||
except AttributeError as ae:
|
||||
LOG.error("Plugin requested unknown parameters.")
|
||||
raise exceptions.PluginRequestedUnknownParameters(
|
||||
plugin=plugin, exception=ae
|
||||
plugin_name=plugin["plugin_name"], exception=ae
|
||||
)
|
||||
try:
|
||||
return plugin["plugin"](**arguments)
|
||||
|
|
@ -364,7 +364,7 @@ class FileChecker:
|
|||
exc_info=True,
|
||||
)
|
||||
raise exceptions.PluginExecutionFailed(
|
||||
plugin=plugin, exception=all_exc
|
||||
plugin_name=plugin["plugin_name"], exception=all_exc
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
"""Exception classes for all of Flake8."""
|
||||
from typing import Dict
|
||||
|
||||
|
||||
class Flake8Exception(Exception):
|
||||
|
|
@ -38,16 +37,16 @@ class PluginRequestedUnknownParameters(Flake8Exception):
|
|||
|
||||
FORMAT = '"%(name)s" requested unknown parameters causing %(exc)s'
|
||||
|
||||
def __init__(self, plugin: Dict[str, str], exception: Exception) -> None:
|
||||
def __init__(self, plugin_name: str, exception: Exception) -> None:
|
||||
"""Pop certain keyword arguments for initialization."""
|
||||
self.plugin = plugin
|
||||
self.plugin_name = plugin_name
|
||||
self.original_exception = exception
|
||||
super().__init__(plugin, exception)
|
||||
super().__init__(plugin_name, exception)
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Format our exception message."""
|
||||
return self.FORMAT % {
|
||||
"name": self.plugin["plugin_name"],
|
||||
"name": self.plugin_name,
|
||||
"exc": self.original_exception,
|
||||
}
|
||||
|
||||
|
|
@ -57,15 +56,15 @@ class PluginExecutionFailed(Flake8Exception):
|
|||
|
||||
FORMAT = '"%(name)s" failed during execution due to "%(exc)s"'
|
||||
|
||||
def __init__(self, plugin: Dict[str, str], exception: Exception) -> None:
|
||||
def __init__(self, plugin_name: str, exception: Exception) -> None:
|
||||
"""Utilize keyword arguments for message generation."""
|
||||
self.plugin = plugin
|
||||
self.plugin_name = plugin_name
|
||||
self.original_exception = exception
|
||||
super().__init__(plugin, exception)
|
||||
super().__init__(plugin_name, exception)
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Format our exception message."""
|
||||
return self.FORMAT % {
|
||||
"name": self.plugin["plugin_name"],
|
||||
"name": self.plugin_name,
|
||||
"exc": self.original_exception,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ from flake8 import exceptions
|
|||
exception=ValueError("boom!"),
|
||||
),
|
||||
exceptions.PluginRequestedUnknownParameters(
|
||||
plugin={"plugin_name": "plugin_name"},
|
||||
plugin_name="plugin_name",
|
||||
exception=ValueError("boom!"),
|
||||
),
|
||||
exceptions.PluginExecutionFailed(
|
||||
plugin={"plugin_name": "plugin_name"},
|
||||
plugin_name="plugin_name",
|
||||
exception=ValueError("boom!"),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue