mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-29 18:46:52 +00:00
Merge branch 'app-make-config-side-effect-free' into 'master'
application: Change `make_config_finder` to be a pure static method See merge request pycqa/flake8!378
This commit is contained in:
commit
e653ab8062
3 changed files with 18 additions and 8 deletions
|
|
@ -30,7 +30,9 @@ def get_style_guide(**kwargs):
|
|||
application = app.Application()
|
||||
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.config_finder = application.make_config_finder(
|
||||
application.program, prelim_opts.append_config
|
||||
)
|
||||
application.find_plugins(prelim_opts.config, prelim_opts.isolated)
|
||||
application.register_plugin_options()
|
||||
application.parse_configuration_and_cli(remaining_args)
|
||||
|
|
|
|||
|
|
@ -133,17 +133,22 @@ class Application(object):
|
|||
(self.result_count > 0) or self.catastrophic_failure
|
||||
)
|
||||
|
||||
def make_config_finder(self, extra_config_files):
|
||||
# type: (List[str]) -> None
|
||||
@staticmethod
|
||||
def make_config_finder(program_name, extra_config_files):
|
||||
# type: (str, List[str]) -> config.ConfigFileFinder
|
||||
"""Make our ConfigFileFinder based on preliminary options.
|
||||
|
||||
:param str program_name:
|
||||
Name of the current programin (e.g., flake8).
|
||||
:param list extra_config_files:
|
||||
List of addtional configuration files to be parsed for
|
||||
configuration.
|
||||
:returns:
|
||||
The configuration file finder
|
||||
:rtype:
|
||||
config.ConfigFileFinder
|
||||
"""
|
||||
self.config_finder = config.ConfigFileFinder(
|
||||
self.program, extra_config_files
|
||||
)
|
||||
return config.ConfigFileFinder(program_name, extra_config_files)
|
||||
|
||||
def find_plugins(self, config_file, ignore_config_files):
|
||||
# type: (Optional[str], bool) -> None
|
||||
|
|
@ -333,7 +338,9 @@ class Application(object):
|
|||
# our legacy API calls to these same methods.
|
||||
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.config_finder = self.make_config_finder(
|
||||
self.program, prelim_opts.append_config
|
||||
)
|
||||
self.find_plugins(prelim_opts.config, prelim_opts.isolated)
|
||||
self.register_plugin_options()
|
||||
self.parse_configuration_and_cli(remaining_args)
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@ def test_get_style_guide():
|
|||
)
|
||||
mockedapp = mock.Mock()
|
||||
mockedapp.parse_preliminary_options.return_value = (prelim_opts, [])
|
||||
mockedapp.program = 'flake8'
|
||||
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.assert_called_once_with([])
|
||||
mockedapp.make_config_finder.assert_called_once_with([])
|
||||
mockedapp.make_config_finder.assert_called_once_with(mockedapp.program, [])
|
||||
mockedapp.find_plugins.assert_called_once_with(None, False)
|
||||
mockedapp.register_plugin_options.assert_called_once_with()
|
||||
mockedapp.parse_configuration_and_cli.assert_called_once_with([])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue