mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 18:56:53 +00:00
application: Rename prelim parsing method to 'parse_preliminary_options'
Positional arguments are not used nor parsed for pre-configuration loading. Thus, renaming the method and updating the docstrings appropriately.
This commit is contained in:
parent
b5157e194d
commit
1abe1d42c2
4 changed files with 11 additions and 22 deletions
|
|
@ -28,10 +28,7 @@ def get_style_guide(**kwargs):
|
|||
:class:`StyleGuide`
|
||||
"""
|
||||
application = app.Application()
|
||||
(
|
||||
prelim_opts,
|
||||
remaining_args,
|
||||
) = application.parse_preliminary_options_and_args([])
|
||||
prelim_opts, remaining_args = application.parse_preliminary_options([])
|
||||
flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file)
|
||||
application.make_config_finder(prelim_opts.append_config)
|
||||
application.find_plugins(prelim_opts.config, prelim_opts.isolated)
|
||||
|
|
|
|||
|
|
@ -98,12 +98,12 @@ class Application(object):
|
|||
#: The parsed diff information
|
||||
self.parsed_diff = {} # type: Dict[str, Set[int]]
|
||||
|
||||
def parse_preliminary_options_and_args(self, argv):
|
||||
def parse_preliminary_options(self, argv):
|
||||
# type: (List[str]) -> Tuple[argparse.Namespace, List[str]]
|
||||
"""Get preliminary options and args from CLI, pre-plugin-loading.
|
||||
"""Get preliminary options from the CLI, pre-plugin-loading.
|
||||
|
||||
We need to know the values of a few standard options and args now, so
|
||||
that we can find config files and configure logging.
|
||||
We need to know the values of a few standard options so that we can
|
||||
locate configuration files and configure logging.
|
||||
|
||||
Since plugins aren't loaded yet, there may be some as-yet-unknown
|
||||
options; we ignore those for now, they'll be parsed later when we do
|
||||
|
|
@ -338,9 +338,7 @@ class Application(object):
|
|||
"""
|
||||
# NOTE(sigmavirus24): When updating this, make sure you also update
|
||||
# our legacy API calls to these same methods.
|
||||
prelim_opts, remaining_args = self.parse_preliminary_options_and_args(
|
||||
argv
|
||||
)
|
||||
prelim_opts, remaining_args = self.parse_preliminary_options(argv)
|
||||
flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file)
|
||||
self.make_config_finder(prelim_opts.append_config)
|
||||
self.find_plugins(prelim_opts.config, prelim_opts.isolated)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ def test_returns_specified_plugin(application):
|
|||
|
||||
def test_prelim_opts_args(application):
|
||||
"""Verify we get sensible prelim opts and args."""
|
||||
opts, args = application.parse_preliminary_options_and_args(
|
||||
opts, args = application.parse_preliminary_options(
|
||||
['--foo', '--verbose', 'src', 'setup.py', '--statistics', '--version'])
|
||||
|
||||
assert opts.verbose
|
||||
|
|
@ -104,10 +104,7 @@ def test_prelim_opts_ignore_help(application):
|
|||
# GIVEN
|
||||
|
||||
# WHEN
|
||||
_, args = application.parse_preliminary_options_and_args([
|
||||
'--help',
|
||||
'-h',
|
||||
])
|
||||
_, args = application.parse_preliminary_options(['--help', '-h'])
|
||||
|
||||
# THEN
|
||||
assert args == ['--help', '-h']
|
||||
|
|
@ -117,6 +114,6 @@ def test_prelim_opts_handles_empty(application):
|
|||
"""Verify empty argv lists are handled correctly."""
|
||||
irrelevant_args = ['myexe', '/path/to/foo']
|
||||
with mock.patch.object(sys, 'argv', irrelevant_args):
|
||||
opts, args = application.parse_preliminary_options_and_args([])
|
||||
opts, args = application.parse_preliminary_options([])
|
||||
|
||||
assert args == []
|
||||
|
|
|
|||
|
|
@ -18,16 +18,13 @@ def test_get_style_guide():
|
|||
verbose=0,
|
||||
)
|
||||
mockedapp = mock.Mock()
|
||||
mockedapp.parse_preliminary_options_and_args.return_value = (
|
||||
prelim_opts,
|
||||
[],
|
||||
)
|
||||
mockedapp.parse_preliminary_options.return_value = (prelim_opts, [])
|
||||
with mock.patch('flake8.main.application.Application') as application:
|
||||
application.return_value = mockedapp
|
||||
style_guide = api.get_style_guide()
|
||||
|
||||
application.assert_called_once_with()
|
||||
mockedapp.parse_preliminary_options_and_args.assert_called_once_with([])
|
||||
mockedapp.parse_preliminary_options.assert_called_once_with([])
|
||||
mockedapp.make_config_finder.assert_called_once_with([])
|
||||
mockedapp.find_plugins.assert_called_once_with(None, False)
|
||||
mockedapp.register_plugin_options.assert_called_once_with()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue