mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 22:04:17 +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)
|
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.find_plugins()
|
||||||
application.register_plugin_options()
|
application.register_plugin_options()
|
||||||
application.parse_configuration_and_cli([])
|
application.parse_configuration_and_cli([])
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class Application(object):
|
||||||
#: The preliminary arguments parsed from CLI before plugins are loaded
|
#: The preliminary arguments parsed from CLI before plugins are loaded
|
||||||
self.prelim_args = None # type: List[str]
|
self.prelim_args = None # type: List[str]
|
||||||
#: The instance of :class:`flake8.options.config.ConfigFileFinder`
|
#: 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
|
#: The :class:`flake8.options.config.LocalPlugins` found in config
|
||||||
self.local_plugins = None # type: config.LocalPlugins
|
self.local_plugins = None # type: config.LocalPlugins
|
||||||
|
|
@ -160,13 +160,18 @@ class Application(object):
|
||||||
(self.result_count > 0) or self.catastrophic_failure
|
(self.result_count > 0) or self.catastrophic_failure
|
||||||
)
|
)
|
||||||
|
|
||||||
def make_config_finder(self):
|
def make_config_finder(self, append_config, args):
|
||||||
"""Make our ConfigFileFinder based on preliminary opts and 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:
|
if self.config_finder is None:
|
||||||
self.config_finder = config.ConfigFileFinder(
|
self.config_finder = config.ConfigFileFinder(
|
||||||
self.option_manager.program_name,
|
self.option_manager.program_name, args, append_config
|
||||||
self.prelim_args,
|
|
||||||
self.prelim_opts.append_config,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def find_plugins(self):
|
def find_plugins(self):
|
||||||
|
|
@ -361,7 +366,7 @@ class Application(object):
|
||||||
argv
|
argv
|
||||||
)
|
)
|
||||||
flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file)
|
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.find_plugins()
|
||||||
self.register_plugin_options()
|
self.register_plugin_options()
|
||||||
self.parse_configuration_and_cli(argv)
|
self.parse_configuration_and_cli(argv)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ from flake8.formatting import base as formatter
|
||||||
def test_get_style_guide():
|
def test_get_style_guide():
|
||||||
"""Verify the methods called on our internal Application."""
|
"""Verify the methods called on our internal Application."""
|
||||||
prelim_opts = argparse.Namespace(
|
prelim_opts = argparse.Namespace(
|
||||||
|
append_config=[],
|
||||||
output_file=None,
|
output_file=None,
|
||||||
verbose=0,
|
verbose=0,
|
||||||
)
|
)
|
||||||
|
|
@ -26,7 +27,7 @@ def test_get_style_guide():
|
||||||
|
|
||||||
application.assert_called_once_with()
|
application.assert_called_once_with()
|
||||||
mockedapp.parse_preliminary_options_and_args.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.find_plugins.assert_called_once_with()
|
||||||
mockedapp.register_plugin_options.assert_called_once_with()
|
mockedapp.register_plugin_options.assert_called_once_with()
|
||||||
mockedapp.parse_configuration_and_cli.assert_called_once_with([])
|
mockedapp.parse_configuration_and_cli.assert_called_once_with([])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue