mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-05 20:46:54 +00:00
change keyword_arguments_for so it does not modify and return
This commit is contained in:
parent
969e8f38d3
commit
f9eb0fd6ea
3 changed files with 16 additions and 15 deletions
|
|
@ -340,13 +340,15 @@ class FileChecker:
|
|||
LOG.debug("Running %r with %r", plugin, arguments)
|
||||
assert self.processor is not None
|
||||
try:
|
||||
self.processor.keyword_arguments_for(plugin.parameters, arguments)
|
||||
params = self.processor.keyword_arguments_for(
|
||||
plugin.parameters, arguments
|
||||
)
|
||||
except AttributeError as ae:
|
||||
raise exceptions.PluginRequestedUnknownParameters(
|
||||
plugin_name=plugin.display_name, exception=ae
|
||||
)
|
||||
try:
|
||||
return plugin.obj(**arguments)
|
||||
return plugin.obj(**arguments, **params)
|
||||
except Exception as all_exc:
|
||||
LOG.critical(
|
||||
"Plugin %s raised an unexpected exception",
|
||||
|
|
|
|||
|
|
@ -241,16 +241,15 @@ class FileProcessor:
|
|||
def keyword_arguments_for(
|
||||
self,
|
||||
parameters: Dict[str, bool],
|
||||
arguments: Optional[Dict[str, Any]] = None,
|
||||
arguments: Dict[str, Any],
|
||||
) -> Dict[str, Any]:
|
||||
"""Generate the keyword arguments for a list of parameters."""
|
||||
if arguments is None:
|
||||
arguments = {}
|
||||
ret = {}
|
||||
for param, required in parameters.items():
|
||||
if param in arguments:
|
||||
continue
|
||||
try:
|
||||
arguments[param] = getattr(self, param)
|
||||
ret[param] = getattr(self, param)
|
||||
except AttributeError:
|
||||
if required:
|
||||
raise
|
||||
|
|
@ -260,7 +259,7 @@ class FileProcessor:
|
|||
"but this is not an available parameter.",
|
||||
param,
|
||||
)
|
||||
return arguments
|
||||
return ret
|
||||
|
||||
def generate_tokens(self) -> Generator[tokenize.TokenInfo, None, None]:
|
||||
"""Tokenize the file and yield the tokens."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue