mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-10 14:54:17 +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
|
|
@ -114,13 +114,17 @@ def test_check_physical_error(error_code, line, expected_indent_char):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('params, args, expected_kwargs', [
|
||||
(['blank_before', 'blank_lines'], None, {'blank_before': 0,
|
||||
'blank_lines': 0}),
|
||||
(['noqa', 'fake'], {'fake': 'foo'}, {'noqa': False, 'fake': 'foo'}),
|
||||
(['blank_before', 'blank_lines', 'noqa'],
|
||||
({'blank_before': True, 'blank_lines': True},
|
||||
None,
|
||||
{'blank_before': 0, 'blank_lines': 0}),
|
||||
({'noqa': True, 'fake': True},
|
||||
{'fake': 'foo'},
|
||||
{'noqa': False, 'fake': 'foo'}),
|
||||
({'blank_before': True, 'blank_lines': True, 'noqa': True},
|
||||
{'blank_before': 10, 'blank_lines': 5, 'noqa': True},
|
||||
{'blank_before': 10, 'blank_lines': 5, 'noqa': True}),
|
||||
([], {'fake': 'foo'}, {'fake': 'foo'}),
|
||||
({}, {'fake': 'foo'}, {'fake': 'foo'}),
|
||||
({'non-existent': False}, {'fake': 'foo'}, {'fake': 'foo'}),
|
||||
])
|
||||
def test_keyword_arguments_for(params, args, expected_kwargs):
|
||||
"""Verify the keyword args are generated properly."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue