mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-07 05:26:53 +00:00
Handle optional parameters that were never supported
Previously, pycodestyle never introspected the argument names for
classes except to require that ``tree`` be an argument it could pass.
For Flake8 3.0, we lifted that restriction, but old plugins seem to
have cargo-culted their __init__ signature to be
def __init__(self, tree, builtins=None):
For some yet unknown reason. This was causing an AttributeError. By
updating flake8.utils.parameters_for to return a dictionary that
indicates whether the parameter is required or not, we can side-step
this by simply ignoring the parameter if it has a default value and
we cannot provide it.
Closes #151
This commit is contained in:
parent
ec2e601cbf
commit
2d3e277b1e
5 changed files with 49 additions and 20 deletions
|
|
@ -206,14 +206,19 @@ class FileProcessor(object):
|
|||
"""Generate the keyword arguments for a list of parameters."""
|
||||
if arguments is None:
|
||||
arguments = {}
|
||||
for param in parameters:
|
||||
for param, required in parameters.items():
|
||||
if param in arguments:
|
||||
continue
|
||||
try:
|
||||
arguments[param] = getattr(self, param)
|
||||
except AttributeError as exc:
|
||||
LOG.exception(exc)
|
||||
raise
|
||||
if required:
|
||||
LOG.exception(exc)
|
||||
raise
|
||||
else:
|
||||
LOG.warning('Plugin requested optional parameter "%s" '
|
||||
'but this is not an available parameter.',
|
||||
param)
|
||||
return arguments
|
||||
|
||||
def check_physical_error(self, error_code, line):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue