mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-29 10:36:53 +00:00
application: Pass prelim opts and args to .make_config_finder()
Now that `.parse_preliminary_options_and_args()` returns options and arguments, the boolean for appending configuration and the arguments can be threaded through to the creation of the `ConfigFileFinder`.
This commit is contained in:
parent
55ef2c6f5e
commit
32ebb4fa55
3 changed files with 15 additions and 9 deletions
|
|
@ -32,7 +32,7 @@ def get_style_guide(**kwargs):
|
|||
[]
|
||||
)
|
||||
flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file)
|
||||
application.make_config_finder()
|
||||
application.make_config_finder(prelim_opts.append_config, prelim_args)
|
||||
application.find_plugins()
|
||||
application.register_plugin_options()
|
||||
application.parse_configuration_and_cli([])
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Application(object):
|
|||
#: The preliminary arguments parsed from CLI before plugins are loaded
|
||||
self.prelim_args = None # type: List[str]
|
||||
#: The instance of :class:`flake8.options.config.ConfigFileFinder`
|
||||
self.config_finder = None
|
||||
self.config_finder = None # type: config.ConfigFileFinder
|
||||
|
||||
#: The :class:`flake8.options.config.LocalPlugins` found in config
|
||||
self.local_plugins = None # type: config.LocalPlugins
|
||||
|
|
@ -160,13 +160,18 @@ class Application(object):
|
|||
(self.result_count > 0) or self.catastrophic_failure
|
||||
)
|
||||
|
||||
def make_config_finder(self):
|
||||
"""Make our ConfigFileFinder based on preliminary opts and args."""
|
||||
def make_config_finder(self, append_config, args):
|
||||
# type: (List[str], List[str]) -> None
|
||||
"""Make our ConfigFileFinder based on preliminary opts and args.
|
||||
|
||||
:param list append_config:
|
||||
List of configuration files to be parsed for configuration.
|
||||
:param list args:
|
||||
The list of file arguments passed from the CLI.
|
||||
"""
|
||||
if self.config_finder is None:
|
||||
self.config_finder = config.ConfigFileFinder(
|
||||
self.option_manager.program_name,
|
||||
self.prelim_args,
|
||||
self.prelim_opts.append_config,
|
||||
self.option_manager.program_name, args, append_config
|
||||
)
|
||||
|
||||
def find_plugins(self):
|
||||
|
|
@ -361,7 +366,7 @@ class Application(object):
|
|||
argv
|
||||
)
|
||||
flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file)
|
||||
self.make_config_finder()
|
||||
self.make_config_finder(prelim_opts.append_config, prelim_args)
|
||||
self.find_plugins()
|
||||
self.register_plugin_options()
|
||||
self.parse_configuration_and_cli(argv)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ from flake8.formatting import base as formatter
|
|||
def test_get_style_guide():
|
||||
"""Verify the methods called on our internal Application."""
|
||||
prelim_opts = argparse.Namespace(
|
||||
append_config=[],
|
||||
output_file=None,
|
||||
verbose=0,
|
||||
)
|
||||
|
|
@ -26,7 +27,7 @@ def test_get_style_guide():
|
|||
|
||||
application.assert_called_once_with()
|
||||
mockedapp.parse_preliminary_options_and_args.assert_called_once_with([])
|
||||
mockedapp.make_config_finder.assert_called_once_with()
|
||||
mockedapp.make_config_finder.assert_called_once_with([], [])
|
||||
mockedapp.find_plugins.assert_called_once_with()
|
||||
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